> Disclaimer: SQL/database newbie here. Nothing wrong with being a newbie :-)
> Let's say I have a table of authors with columns for last name and first > name. Is there any general guideline re using a separate integer for the > primary key as opposed to a combination of the last and first names as the > key? I ask because by using the names, this would prevent > duplicate entries > into the db, right? Whereas using a separate integer key would > not prevent > this--you'd have to search for the author to see if it was > already in the db > before inserting to avoid dupes, right? > > Assume I am not concerned about there being two different "Joe Smith" > authors that are different people. I only want to associate an > author name > with a book. Your observations are correct -- as long as you're only concerned about that one table. But as soon as you start entering books (which I assume you do in another table), you have to link the two tables somehow. The most obvious way to do this is to carry over the primary key from the author's table, in your case first and last name -- just as you suggest. BUT - and here's why you should use an integer instead. 1) Strings generally take up more space than integers - and as you will probably be storing lots of data in your books table, the strings first and last name will be stored over and over, taking up more space than would an integer. 2) Maybe more importantly: Suppose you discover that an author's name is misspelled -- you'll only have one place to make the update, rather than every table referenced by the first/last name combo. BTW, there's nothing to stop you from adding another unique index besides the primary. See the CREATE TABLE / ALTER TABLE commands in the manual. This would prevent you from inserting any duplicates. / Carsten -- Carsten H. Pedersen keeper and maintainer of the bitbybit.dk MySQL FAQ http://www.bitbybit.dk/mysqlfaq --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php