Re: db setup - correction

2009-02-10 Thread PJ
Peter Brawley wrote: PJ, As I understand it, I have one table books it lists all the info for the book other than the author(s) or the categories ; for these I need an authors table and a category table... I'll continue with the authors as categories will surely be the same thing. BTW, I

Re: db setup - correction

2009-02-10 Thread Peter Brawley
PJ But what about foreign keys? Don't I need that to find the relationships between the books, the authors and the categories? After all, isn't this a relational db? If so, I can't use the default engine (MyISAM) which does not support FK. So, if I have to use foreign keys, I have to change to

Re: db setup - correction

2009-02-10 Thread PJ
Peter Brawley wrote: PJ But what about foreign keys? Don't I need that to find the relationships between the books, the authors and the categories? After all, isn't this a relational db? If so, I can't use the default engine (MyISAM) which does not support FK. So, if I have to use foreign

Re: db setup - correction

2009-02-10 Thread Peter Brawley
PJ PBEngine choice is another issue. InnoDB properly isolates FK enforcement in the database. The MyISAM tradeoff (for speed) is that you have to implement FK logic in code. PJForgive my naiveté, but how do you do that? You write application code to implement the equivalent of ON DELETE

Re: db setup - correction

2009-02-10 Thread ddevaudreuil
PJ af.gour...@videotron.ca wrote on 02/10/2009 12:44:04 PM: -- - -- Table `books` -- - CREATE TABLE IF NOT EXISTS `books` ( `id` SMALLINT(4) UNSIGNED NOT NULL AUTO_INCREMENT ,

Re: db setup - correction

2009-02-10 Thread PJ
ddevaudre...@intellicare.com wrote: PJ af.gour...@videotron.ca wrote on 02/10/2009 12:44:04 PM: -- - -- Table `books` -- - CREATE TABLE IF NOT EXISTS `books` ( `id` SMALLINT(4)

Re: db setup - correction

2009-02-09 Thread Olaf Stein
Just about the authors You need a separate table for them and then an table linking authors and books. So you have table books, authors and rel_books_authors where rel_books authors has 3 entries for a book with 3 authors just using the book id and the author is's Olaf On 2/9/09 10:25 AM, PJ

Re: db setup - correction

2009-02-09 Thread PJ
Olaf Stein wrote: Just about the authors You need a separate table for them and then an table linking authors and books. You lose me here... :-( Why do I need a third table? I may have 2 or three books with 3 authors, quite a few with 2 authors and many with just 1 author. I can't see

Re: db setup - correction

2009-02-09 Thread Peter Brawley
PJ Why do I need a third table? The clue is author (could be 2 or more) in your books column list. It is incorrect to store two author names or IDs in one column. The relationship is 1:many. So you need a bridge table: books(id PK, etc...) authors(id PK, etc...) books_authors(id PK, bid

Re: db setup - correction

2009-02-09 Thread Olaf Stein
See normalization... You don't need to do this but it is considered good practice for many reasons On 2/9/09 12:04 PM, Peter Brawley peter.braw...@earthlink.net wrote: PJ Why do I need a third table? The clue is author (could be 2 or more) in your books column list. It is incorrect to

Re: db setup - correction

2009-02-09 Thread PJ
Peter Brawley wrote: PJ Why do I need a third table? The clue is author (could be 2 or more) in your books column list. It is incorrect to store two author names or IDs in one column. The relationship is 1:many. So you need a bridge table: books(id PK, etc...) authors(id PK, etc...)

Re: db setup - correction

2009-02-09 Thread Olaf Stein
Book table: book id : 1, name: some book name Author table Author id: 1, name: author 1 Author id: 2, name: author 2 Rel_author_book table: Book id: 1, author id: 1 Book id: 1, author id: 2 Same with categories and other 1:N relations Olaf On 2/9/09 2:01 PM, PJ af.gour...@videotron.ca

Re: db setup - correction

2009-02-09 Thread Peter Brawley
PJ, As I understand it, I have one table books it lists all the info for the book other than the author(s) or the categories ; for these I need an authors table and a category table... I'll continue with the authors as categories will surely be the same thing. BTW, I cannot use ISBN as PK since