Results 1 to 3 of 3
  1. #1
    niloufar is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    24

    How To Design My Table?

    Hello everyone I am creating a reporting system and I have two tables from students and one table from training. I need to join these tables and remove duplicates. however I have to normalize my tables first. The both have so many problems. Because at the end when I Union two tables I get duplicates result.

    My first question is, how to design my training table, because students is simple and their IDs are uniq so I can have PK; however, I have one excel sheet with student many similar students IDs that have taken many training.

    Student Table




    ID Name DOB
    1 AA 1/1/88
    2 ABC 1/1/88
    3 ADE 1/1/88
    4 AFG 1/1/88
    5 BHI 1/1/88
    6 JFH 1/1/88



    Training Table

    ID Name Course
    1 A Course-A1
    1 A Course-A2
    1 A Course-A3
    2 A Course-A4
    2 B Course-A1
    2 B Course-A2
    2 B Course-A3
    2 B Course-A4
    3 C Course-A1


    How I suppose to design this table? PK? Index? or normalize ? and HOW?

    When I combine my both tables to get all student names who has taken or not taken the course, I get duplicate ID and name; BUT if I take the name out then I get right number of IDs:

    CODE
    SELECT DISTINCT CurrentStudent.[Student ID], CurrentStudent.[Student Name]
    FROM (SELECT Student.[Student ID], Student.[Student Name]
    FROM Student
    GROUP BY Student.[Student ID], Student.[Student Name]

    Union

    SELECT Training.Username, Training.[Student Name]
    FROM Training
    GROUP BY Training.Username, Training.[Student Name]

    ) AS CurrentStudent
    ORDER BY CurrentStudent.[Student ID];


    Thank you

  2. #2
    hansendl is offline Advanced Hobbyist
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    38
    You have a many-to-many relationship between students and courses, so you'll need three tables:

    tblStudents:
    StudentID (PK)
    LastName
    FirstName
    ...

    tblCourses:
    CourseID (PK)
    Title
    Description
    Classroom
    ...

    tblStudentCourses:
    StudentID
    CourseID

    Both StudentID and CourseID together will form the PK for tblStudentCourses. Also, you'll need to establish a one-to-many relationship between tblStudent-->tblStudentCourses and between tblCourses-->tblStudentCourses.

    If this thoroughly confuses you, recommend you do some reading on many-to-many relationships and how to normalize these types of relationships in an RDMS.

    Good luck!

  3. #3
    niloufar is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    24
    Great, thank you very much

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

Similar Threads

  1. Replies: 3
    Last Post: 04-27-2014, 08:08 PM
  2. Table Design
    By Hunter in forum Database Design
    Replies: 1
    Last Post: 03-02-2013, 11:51 AM
  3. Table Design -- want to avoid a design that creates blank fields
    By snowboarder234 in forum Database Design
    Replies: 4
    Last Post: 10-08-2012, 10:13 AM
  4. Replies: 8
    Last Post: 03-24-2012, 11:03 AM
  5. table design: one big table vs. multiple small tables
    By lstairs in forum Database Design
    Replies: 3
    Last Post: 12-31-2009, 08:46 AM

Tags for this Thread

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