views:

51

answers:

2

Hi,

We would like to create a training database in SQL which we can use for our internal training sessions of our employees. Unfortunately I do not have any experience in database design and did not have a chance to buy and read a proper book about this topic.

I have just started to create a database after reading a few tutorials online and would like you to review my design and provide me with some feedback if I have started more or less correct.

The courses table will store our training courses with their duration, capacity and a small description of what you will learn on this course. The training session table will be used to link a course with a specific training and a date when the training will be done. The trainers are colleagues who provide the internal courses.

The attendance table stores the training session id and if an employee attended the session or if he could not.

Please find below our database diagram:

alt text

Later on we would also like to store the job position a training course is relevant for. For example our network introduction course is relevant for a Level 1 Analysts, a Level 2 Analysts and Team Leaders. Our ITIL course is relevant only for a team leader.

How would you store this information? Would you use a separate table with the positions and use a many to many relationship for this?

Many thanks,

Mathias

+1  A: 

The structure seems fine. I'd suggest adding one more foreign key relationship, though: Attendance.EmployeeID should reference the Employee table.

Attendance doesn't need its own primary key. The combination of employee and session uniquely identifies it (a given employee can't attend a given session more than once, can they?). You should probably use the two ID columns for those as a composite primary key.

Do courses really have a capacity, or is it a session which has a capacity?

What's the UpdateTime column for?

Tom Anderson
Hi Tom, many thanks for feedback. You are right, a given employee can attend a given session only once. Regarding the capacity comment you are also right. It is the session that has a capacity for X trainees instead of the course. I will change the tables accordingly. The UpdateTime column I have added to have a timestamp when a record was added. Maybe I will drop this this column in the future. Could you also give me an advise on the course - job position question (question below the diagram)?Many thanks for your help!Mathias
mathias florin
+1  A: 

A bit simplified, does not account for enrolment, but may help you with ideas.

alt text

Damir Sudarevic
Hi Damir, many thanks for the diagram. This explains even further how to structure the design. I really appreciate that you took some time to draw this. This gate that says EmployeeType, what does it mean? In our case an Employee can be a teacher for one course and a student for another one. Could you tell me which software you have used to draw this diagram? Thanks! Mathias
mathias florin
Exclusive Sub-Type (sub-category) -- EmployeeType T=teacher, S=Student. Use inclusive sub-type (drop EmployeeType column) to have an employee as a student and/or teacher. Employee table has all common columns, while Student and Teacher just specific columns for each one. It may be that you do not need the Student table (all common fields are in Employee), just the Teacher one. Diagram drawn using ERwin (community ed)http://erwin.com/products/detail/ca_erwin_data_modeler_community_editionAlso see herehttp://stackoverflow.com/search?q=user:196713+subtypefor more (exclusive) subtypes.
Damir Sudarevic