can foreign key have same values ?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dkshri_jain
Forum Newbie
Posts: 8
Joined: Tue Dec 27, 2005 12:03 am
Location: India
Contact:

can foreign key have same values ?

Post by dkshri_jain »

can foreign key have same values ?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Yes, you can have multiple records that all have the same value for an attribute that is a foreign key..

eg:

books (bookid, title, authorid)
(1, 'tim meets tiny', 2)
(2, 'tiny dumps tim', 2)

authors (authorid, name)
(2, 'Jezus')
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: can foreign key have same values ?

Post by Roja »

dkshri_jain wrote:can foreign key have same values ?
Which database system? Did you try it?
Post Reply