February 27, 2009 at 2:41 pm
Hi,
This is a question about properly inserting values in a many-to-many relationship tables. For example let us say that Author and Book are the two primary tables and Wrote is the link table. Despite the relationship, one could independly insert values in either the Author or the book table, without any relationship violation. If this happens, without the corresponding insert of the link table, then the link table becomes not of much use. My question is at what point the link table has to be forced to be inserted?
Thanks
February 27, 2009 at 3:12 pm
Here's my take on this issue. As far as the database is concerned you never have to have a row in the link table. A book with corresponding rows in the link table has no authors while an author with no corresponding rows in the link table has written no books or at least no books that are in the database.
I think of it this way, when I enter a new book my UI will ask for an author, then I either pick an existing author or enter a new one (saving this information), then when I save the book entry I create the book row and the link table row or rows with book_id and author_id. In theory you could allow the user to save a book without entering an author and then have a report where the users can go back and enter authors for books without authors.
You could start with the Author as well and assign books to the author.
I think it is more process than database.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
February 27, 2009 at 4:36 pm
Thanks. That resolves my question.
Thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply