Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Posts
    4

    Many to Many relationship

    Hi

    I have a database with 5 tables for tracking employee training. The tables are

    Employee Info. Primary key is autonumbered and table is normalized
    Positions "


    Courses "
    Departments "
    Courses Required for Position. This only has four fields. The id which is autonumbered, the position number, course number and months valid.

    Competency. This is a table which records which courses have been completed by each employee. It has the employee id, position id, course id, date completed, score. I don't have a primary key for this one yet.
    I have created relationships from the first four tables to other tables where info is repeated (one to many)

    My problem is, I need info from the last two tables in one view. I want to create a query that will show ALL of the courses required for each employee (that I can do) with the courses completed marked as complete (that I can't do), so for example if an employee is required to take 50 courses, I want to see all fify in the result with a field that marks which ones are complete and which are not. I need to combine the info from both the courses requried and the competency tables and I can't seem to do that. I don't know if it is a relationship issue or what. These tables have a many to many relationship. I have them both related to the other tables, but I can't seem to get the results.

    I would appreciate any help I can get.

    Marlie

  2. #2
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    Marlie,

    You're on the right track. I'd go with something like:

    tblEmployees
    ---------------------------------------------------
    EmpID (PK)
    PosID (FK)
    EmpLName
    EmpFName
    <other employee attributes>

    tblPositions
    ---------------------------------------------------
    PosID (PK)
    PosTitle
    DeptID (FK)
    <other position attributes

    tblCourses
    ---------------------------------------------------
    CourseID (PK)
    CourseTitle
    <other course attributes>

    tblDepartments
    ---------------------------------------------------
    DeptID (PK)
    DeptName
    <other dept attributes>

    tblCoursesReqd
    ---------------------------------------------------
    PosID (PK, FK)
    CourseID (PK, FK)
    DaysValid
    PassingScore

    tblCoursesTaken
    ---------------------------------------------------
    EmpID (PK, FK)
    CourseID (PK, FK)
    DateCompleted
    EmpScore


    The changes/assumptions I made compared to your original structure:

    1) On some tables I suggest a multi-field primary key

    2) I am explicitly tying the position to the department, so if 2+ departments have similar positions, they need two records in the position table. This may not be quite what you want.

    3) I removed position number from your competency table: if the employee table indicates the employee's position, then there is no need to duplicate that data on the competency table (that would, indeed, break the normalization rules)

    4) I changed the interval for how long a course is from months to days, as days are easier to calculate and less prone to ambiguity

    5) I added a concept of a "passing score"



    Once you've got a db with some data in it, if you post the mdb file I could see about generating the SQL to return the results you're looking for.

  3. #3
    Join Date
    Aug 2006
    Posts
    4
    Thanks

    I really appreciate this help.

    How do I post a file in here.? I don't see any attachment icons or instructions. Would you prefer I send it to you in email?

    Marlie

  4. #4
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    Marlie,

    I'd prefer that you upload the file to a publicly accessible site; that way, other people reading the question might benefit. If you do not have web space of your own, you may want to get free web space at www.geocities.com.

  5. #5
    Join Date
    Aug 2006
    Posts
    4
    Thanks

    Marlie

  6. #6
    Join Date
    Aug 2006
    Posts
    4
    Hi

    The database is already populated with thousands of records. It is confidential so I won't be posting it. I know I could create bogus data, but I don't have the time, so I will do what I can with it and hope for the best.

    Thanks for your time

    Marlie

  7. #7
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    Marlie,

    In that case, if you send me a slimmed down db privately, if I have time next week I can work on a query or two.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. design using relationship...
    By dsnyder in forum Database Design
    Replies: 2
    Last Post: 10-21-2008, 12:00 PM
  2. Many-to-Many Relationship
    By Carolyn1 in forum Database Design
    Replies: 0
    Last Post: 09-25-2006, 02:04 PM
  3. one to many relationship
    By pe_z in forum Database Design
    Replies: 2
    Last Post: 02-17-2006, 10:44 PM
  4. Replies: 0
    Last Post: 02-16-2006, 09:11 AM
  5. MAY TO MANY RELATIONSHIP
    By fadone in forum Database Design
    Replies: 2
    Last Post: 12-20-2005, 09:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums