In a university database, I have a self referencing relationship for a subject and a pre-requisite. Meaning that a subject can have 0 or more pre-requisites.
So I declared it in a table for subjects
subject_code VARCHAR(7) NOT NULL CONSTRAINT subject_pk PRIMARY KEY,
subject_name VARCHAR(50) NOT NULL,
pre_requisite VARCHAR(7) NULL CONSTRAINT unit_pre_code FOREIGN KEY
REFERENCES subject(subject_code),
So I am just wondering if I am right heading this way or should there be another table that deals with pre-requisites.
If I am in the right track, how do I insert a data that has a pre-requisite for the subject? for example C++(C12345) subject is a prerequisite to Operating Systems(C34512) or something. I am still really new to this and I'm having a hard time looking for good and simple references for SQL. Any recommendations would be great too!