Re: database for books question
| From: | John Meyer | Date: | Sun, 22 Jan 2006 00:14:00 +0000 |
| Subject: | Re: database for books question | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41107@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Flint Million wrote:
> Good idea. OK so I'll create a new database with subject ID's. Now, back in
> the primary database, how can I have multiple subjects assigned to one book?
> Let's say I repeat my above example and we assign "Nonfiction" to 1,
> "Technology" to 4, and "Linux" to 5. I know I might be getting off PHP
> topic
> here, but what's the best way then to have the database be able to reference
> multiple subjects per record? Or, would I have to do like "subject0 subject1
> subject2 etc." fields considering the maximum number of subjects per book? I
> still want to be ao search by subject and any book that has that particualr
> subject assigned to it would be returned.
>
Here's how
Table:
BOOKS
BOOK_ID
BOOK_NAME
....
PK: BOOK_ID
SUBJECTS
SUBJECT_ID
SUBJECT_NAME
PK: SUBJECT_ID
BOOK_SUBJECT
BOOK_ID (references BOOKS)
SUBJECT_ID (references SUBJECTS)
PK: (BOOK_ID,SUBJECT_ID)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFD0s5Hj60GAoLuoDkRAlu2AJ4wqmitcKOpSwxiosJIrxHRr4swEACfUy4N
biTma4v6Kw5ZWps879Xa9Jg=
=D0Nk
-----END PGP SIGNATURE-----