0

Entity Relationship Diagram

Hi guys i am currently working on a erd for a attendance system. I have 6 tables (Class,Programme,Faculty, User(Lecturer/Admin), Attendance and Student. I have a primary key of p_code in "Programme" table and i was wondering if the "p_code" can be a foreign key in Student table?. Because from what i have learnt previously was that any "people" table cant have any foreign key is it true?

9th Jun 2018, 3:42 PM
Dexter Siah
Dexter Siah - avatar
2 Réponses
+ 7
You have to understand the rationale behind having a foreign key. What is the relationship between Student and Programme? Can one student participate in many programmes? Can a programme be participated by may students? If both of these cases are true, then you have a many-to-many relationship. Placing p_code as foreign key in Student would result in redundancy. You can resolve this by having a bridge entity to store the records of student and their programmes, e.g. Student_Programme, with attributes: sp_code (primary key) s_code (foreign key, Student) p_code (foreign key, Programme)
9th Jun 2018, 4:14 PM
Hatsy Rei
Hatsy Rei - avatar
0
The relationship between my Student and Programme table is one student can participate in only 1 Programme but 1 Programme can have many students.
10th Jun 2018, 6:26 AM
Dexter Siah
Dexter Siah - avatar