Re: IS it a good practice to use SERIAL as Primary Key?
От | Michael Glaesemann |
---|---|
Тема | Re: IS it a good practice to use SERIAL as Primary Key? |
Дата | |
Msg-id | B2E16C01-4C2A-40C5-A836-606B0E6D7033@seespotcode.net обсуждение исходный текст |
Ответ на | Re: IS it a good practice to use SERIAL as Primary Key? ("Joshua D. Drake" <jd@commandprompt.com>) |
Ответы |
Re: IS it a good practice to use SERIAL as Primary Key?
|
Список | pgsql-general |
On Nov 28, 2006, at 9:02 , Joshua D. Drake wrote: > On Mon, 2006-11-27 at 17:31 -0600, John McCawley wrote: >> I promise I'm not trying to be a pain in the butt ;) Do you then use >> your serial id as your foreign key in other tables, or the >> firstname/lastname primary key? > > Now that is a good question. I would use the id, but that is not > technically proper :). If you have both a surrogate key (the serial column) as well as a natural key (e.g., the (first_name, last_name) composite key), what difference does it make? You can get to the first_name, last_name data via a join on the surrogate key. I'm currently loosely in the surrogate key + natural key camp. One advantage of this is that if there *is* a change to the natural key, it can be changed in one table rather than cascading throughout the database schema. Michael Glaesemann grzm seespotcode net (Can we talk about NULL next? :P)
В списке pgsql-general по дате отправления: