Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8507627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:55:28+00:00 2026-06-11T02:55:28+00:00

If I had two foreign keys in a table referencing the same primary key

  • 0

If I had two foreign keys in a table referencing the same primary key in another table, what type of relationship is this? One to many? or One to One?

For example:

Table Author has primary key AUTHOR_ID

Table Book has two foreign keys PRIMARY_AUTHOR_ID and SECONDARY_AUTHOR_ID both reference AUTHOR_ID

What type of relationship is this?

*I know the author book example could be handled in a better way, I am just using those fields for an example.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:55:29+00:00Added an answer on June 11, 2026 at 2:55 am

    It looks like your setting up a 1..[1-2] relationship between a Book and its Author(s). In other words, you have a 1..1 relationship between a Book and a primary Author, and you effectively have a 1..[0-1] relation ship between a Book and a secondary Author. One could argue that as a result you have a 1..[1-2] relationship between a Book and its Author(s).

    This considers only one direction of the equation, because obviously an Author can also have multiple books, so the real relationship is more like N..[1-2] between Books (plural) and Author(s), depending on the notation and methodology one uses.

    I realize that you have just contrived an example so that you can ask the question. In regard to use of this construct, I’d advocate that you should consider a more general construct of the N..M relationship (between Books and its Author(s). From an design perspective, one thing you don’t want to do is hard code too much business logic into your structural representation. It is common for initial business rules to suggest that you have a limited (1..1 or 1..N) relationship and later the business requirements (subtly or perhaps not so subtly) change such that now you need to be able to model N..M. This then means a schema change, which is certainly possible, but in some cases foresee-ably avoidable and you have the option to be less brittle. (It’s another way of saying that premature optimization is the root of all evil.)

    You probably already know this, though perhaps for the benefit of others, to get to N..M you’d remove both the foreign keys from the BOOKS table, and introduce a third table: BOOKS_AUTHORS, which would have a foreign key to table BOOKS (BOOK_ID) and another to AUTHORS (AUTHOR_ID). You can also add a column to designate author order, to sequence the authors, for primary, secondary, tertiary, etc…

    (NOTE: I tend to name tables using plural, e.g. BOOKS, since the table is a collection, and a Book is a row as a member of the BOOKS table. Of course, from OOP, you’d tend to name a class using singular, e.g. BOOK, a Book is a instance of the class BOOK — just terminology, mostly.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this question I was having problem with saving objects that had foreign keys
I have a projects table which has two foreign keys for users (user_id and
I am using Enum data type as a primary key referenced as a Foreign
I have two objects that are linked by a foreign key relationship and I
If I had two tables? <table class=one> and... <table class=two> And the CSS looks
I had two separate interfaces, one 'MultiLingual' for choosing language of text to return,
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is
NOTE: I had two variables with the same name... Big thanks to Stefan Birladeanu
If i had two different application running under the same solution but using different
This is a link to a question I had asked two days back, How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.