Re: How to deal with identical fields in db

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 4:34 PM -0400 5/5/09, PJ wrote:
I'm coming up with a bit of a quandry: how to enter and retrieve an
identical book title with different authors.
It is rather unbelievable what contortions one finds as authors :-(
like editors, associations and then the unknowns and anon y mouses.
I suppose one has to get really creative...
Anyone for tea?

You need to normalize.

Authors should have an unique id in an authors table. The authors table has all the specific information about authors, but not the books they have written.

Books should have an unique id in a books table. The books table has all the specific information about books, but not the contributing authors.

Then you connect the two tables with a Book-Author table that has only the id's of both -- no real need for any other information.

That way when you want to see all the books an author has written, then you pull out all the records that has the author's id and look up each book via the book id.

Likewise, when you want to see all the authors who have contributed to a book, then you pull out all records that has the book's id and look up each author via their author id.

Do you see how it works?

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux