Re: Simple Database Design Problem
Posted by: Filip Nedyalkov
Date: June 13, 2011 03:04AM

Sorry mate, but I have no idea what to do with that.

Let me put my problem into a different example:

You have table BOOKS and table AUTHORS. The relationship is many to many.

So the tables would look like this:

BOOKS:
ISBN 1590593324
Title Beginning MySQL Database Design and Optimization
Pages 520

AUTHORS:
Author_ID 1 2 3
First_Name Chad Jon Mike
Last_name Russell Stephens Hillyer

So each book can have many authors and each author can have many books.
Note: In my example this is like each component can be used in many templates and each template can have many components.

Here is the table that makes the connection:
ISBN 1590593324 1590593324
Author_ID 1 2

In this case 1 book has 2 authors.

So here is a scenario:
1) I have added 10 authors to my table of authors.
2) I add a new book to my book table

Questions:
1) How do I know which authors from that 10 I have are the authors of this book ?

What I need to do is: detect if the authors are in the authors table ->
-> select them if they are there and insert the new data to the rest of the tables
-> insert the new authors in the authors table if they are not there and insert the new data to the rest of the tables

Is that possible to happen automatically? Or user interaction is a must - meaning that when adding a book the user must review if the authors are there add new if they aren't and then select them and save the book data?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.