Results 1 to 4 of 4
  1. #1
    alexthefourth is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    6

    Can I use same field twice in a table

    I have a courses table which has information about courses. It has the following Fields: courseID, Professor, Units.

    There is another table called prereq which has prereq id as the primary key. courseID is a foreign key in the prereq table because one course can have many prereqs. The prereq table also has a field called prereqname which simply gives the name of the course that is a prereq.

    So right now if i want to find all of the prereqs of a specific course I only get the name.



    Is there a way to use the courseID a second time in the prereq table so that when i want to find the prereqs of a specific course I can get all of the course data of the prereqs?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Can use the same data in multiple fields. Consider:

    tblPreReqs
    PreReqID (autonumber, this field might not be needed)
    PrimaryCourseID (foreign key for the course)
    PreReqCourseID (foreign key for the course)

    Set the two CourseID fields as compound primary key and duplicate pairs won't be allowed.

    Not every course will be in this table. Only need to have in PrimaryCourseID field if course has prerequisites that will be listed in PreRegCourseID. If a course has no prerequisites then no record required. Many courses will be in both fields.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alexthefourth is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    6
    Thank You,

    and when i run a query to display each courses prereqs how can i use PreReqCourseID to grab the CourseName, Professor, and units which is located in the Course table?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Include Course table in the query twice, one to each of the CourseID fields.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-16-2013, 09:05 AM
  2. Replies: 5
    Last Post: 11-01-2012, 09:26 AM
  3. Replies: 5
    Last Post: 06-19-2012, 10:46 AM
  4. Replies: 1
    Last Post: 08-31-2011, 04:03 PM
  5. Replies: 3
    Last Post: 08-26-2011, 12:11 PM

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