Say there is a database for students and professors (a very simple one) and the relational database is the following:
GradStudent (_id_, name, gradStuff)
UndergradStudent (_id_, name, underGradStuff)
Professor (_id_, name)
Teaches(_prof_id_, _stud_id_)
Considering that the relational database above is meant to represent total disjoint specialization, i.e. there is no table Student
but rather two completely seperate ones, when writing this in SQL in order to implement the database, how would I fetch the student id for the Teaches
table?
I cannot figure out how to make a foreign key from two different tables.
I am writing this question assuming that the SQL language is not all the different across all the platforms. If clarification is needed: I am working on Oracle SQL Developer.
Edit :: additional info / Clarification:
For a more graphical, simplistic view on what I am trying to achieve:
I want to write the following in SQL code (however I do not know how is it possible and thus don't know how to)
My apologies if the picture is too simplistic, if needed I can add more attributes and details, just let me know.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…