Jump to content

Can a foreign key reference a unique non-primary key?


proud

Recommended Posts

Hello everyone, I have 2 tables: [books] with the fields (id, title,author,isbn) and another table called [book issue] with the fields (id, borrower_id, borrow_date, book_isbn)..

Now the field (book_isbn) in the [book issue] table references (isbn) in the books table, which is a unique field but not a primary key.

 

My questions:

 

1- Is it correct for a foreign key to reference a unique but non-primary key in another table?

 

2- Is it okay for the foreign key field to have a different name than the field it references in the other table?

 

Your help is indeed appreciated..

Link to comment
Share on other sites

1. Yes

2. Yes

 

 

3. I would avoid using ISBN as a field referencing anything in database. I've been working in book publishing business for some time and have seen my sort of fscked up ISBNs along the way.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.