-2
$\begingroup$

I have two tables, course and prereg.

The attributes are like that,

course(course_id, title, dept_name, credits)

prereg(course_id, pre_id)

course_id attribute, of course, is the primary key.

course_id, pre_id attribute, of prereg, is the primary key.

On the other hand,

The attribute course_id in prereg is a foreign key from prereg referencing course.

I would like to know how could it be possible? At the same time, how can course_id become both primary key and foreign key?

The table is taken from the University schema of Database System Concept.

$\endgroup$
3
  • 1
    $\begingroup$ What do you mean, "how could it be possible"? For the reasons we have CKs, PKs & FKs. Tell us what is stopping you. Quote the definitions those terms. Right now that's about all we can do for you ourselves. Until you do that, this post is just a duplicate for asking what each of those things is. And are those two questions supposed to be together asking one question?? This post is not clear. As with your other recent questions: Re homework. Re research effort. 1 question. Etc etc. How to Ask $\endgroup$
    – philipxy
    Sep 17 at 4:32
  • $\begingroup$ Does this answer your question? What does this definition of a Primary key mean? $\endgroup$
    – philipxy
    Sep 17 at 5:06
  • $\begingroup$ Read the tag wiki for tag reference-request. It is not about referential integrity or referencing via FK or databases & it doesn't belong here. $\endgroup$
    – philipxy
    Sep 17 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.