CHECK versus a Table for an enumeration

Поиск
Список
Период
Сортировка
Hi all!

I want to know what's better between these 2 solutions :

CREATE TABLE user (
...
user_type   text     CHECK(user_type='Root' OR user_type = 'Admin' OR
user_type = 'Standard'));

or the following :

CREATE TABLE user_type(
user_type_id     integer   PRIMARY KEY,
user_type_desc text);

CREATE TABLE user (
...
user_type_id   integer,
CONSTRAINT user_type_exists FOREIGN KEY (user_type_id) REFERENCES
user(user_type_id));

I am really confused so I'll wait for your advices.

Thanks,

Melanie


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

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: hardware requirements under Redhat (fwd)
Следующее
От: Melanie Bergeron
Дата:
Сообщение: Re: Add Primary/Foreign Key in 7.3.2