954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Foreign Keys

Suppose I have this two tables;
Modules and Student

Modules has the following fieldsModule_Code(Primary Key)
Module_Name

Student has the following fieldsStud_Number(primary key)
Stud_FullName

My problem is that I want to include the Stud_Number on the Modules table to make it a primary key.

Can anyone show me the right syntax to use because I have through the Documentations and still I cannot find the right syntax to use.

Best Regards
Goitse
:confused:

Goitse
Newbie Poster
13 posts since Oct 2006
Reputation Points: 12
Solved Threads: 0
 

Suppose I have this two tables; Modules and Student

Modules has the following fields

  • Module_Code(Primary Key)

Module_Name

Student has the following fields

  • Stud_Number(primary key)

Stud_FullName

My problem is that I want to include the Stud_Number on the Modules table to make it a primary key.

Can anyone show me the right syntax to use because I have through the Documentations and still I cannot find the right syntax to use.

Best Regards Goitse :confused:

Why would the student id be included in the modules table?

I assume a student may have zero, one or many modules and a module may have zero, one or many students.

What I think you need is a many to many relationship with a middle table

students ----< modules_students >---modules

modules_students would have have the columns student_id and module_id; so to add a student to a module you'd add a tuple in modules_students with the student's id and the module's id.

pty
Posting Pro
530 posts since Oct 2005
Reputation Points: 64
Solved Threads: 39
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You