Re: IS it a good practice to use SERIAL as Primary Key?

Поиск
Список
Период
Сортировка
От Daniel Serodio
Тема Re: IS it a good practice to use SERIAL as Primary Key?
Дата
Msg-id 1164720879.223957.276640@l39g2000cwd.googlegroups.com
обсуждение исходный текст
Ответ на Re: IS it a good practice to use SERIAL as Primary Key?  ("Joshua D. Drake" <jd@commandprompt.com>)
Список pgsql-general
"Joshua D. Drake" wrote:

<snip/>

>
> That's it, in a nut shell. There is no argument there. That is why you
> don't use artificial keys. That said... pretty much every table I create
> will have an artificial key... because it makes managing data easy. An
> example (to reuse the simple example):
>
> users
> =====
> id serial unique,
> first_name text,
> last_name text,
> primary key (first_name,last_name)

Why not

users
=====
id serial primary key,
first_name text,
last_name text,
unique (first_name, last_name)

? This way, you can use the "id" as foreign key (more efficient),
allows you to "UPDATE first_name" if needed, and if you find out you
need to add another Joshua Drake to the DB, all you need is to drop the
unique constraint?


В списке pgsql-general по дате отправления:

Предыдущее
От: "Terry Yapt"
Дата:
Сообщение: [Windows] Pg_Restore on 8.1.5 and so on...
Следующее
От: Bill Kurland
Дата:
Сообщение: Re: AIX and getaddrinfo