Skip to content
Advertisement

Is this ERD correct?

ERD

This ERD is part of my school work and something doesn’t seem right. The ERD table ‘Course’ looks like its referencing 2 tables. Is the column titled ‘Qual_Code’ in table ‘Course’ from the ‘Prerequisite’ table, the ‘Qualification’ table or both? I don’t think its both because you cannot have a single column with a foreign key that references two different tables. Help because I have to write the SQL codes for this!

Advertisement

Answer

At the first glance, it appears that the column qual_code of the COURSE table is redundant. When writing the DDL code for this, you can include or exclude this column – see the following examples:

course table with qual_code column

course table without qual_code column

The PREREQUISITE table maps courses to qualifications. The PK constraint in this table will not allow NULLs in either of the columns ie if a row gets INSERTed, it must contain values for both course_num and qual_code.

I don’t think its both because you cannot have a single column with a foreign key that references two different tables.

It seems that you are misinterpreting this. The PK column of the QUALIFICATION table is referenced twice (FK columns reference a PK or UNIQUE column, not the other way round -> see the DDL code on DBfiddle).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement