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.
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.)