Advice on key design

Поиск
Список
Период
Сортировка
От JORGE MALDONADO
Тема Advice on key design
Дата
Msg-id CAAY=A7_ZKoCRjP19oLRYfQeV1=Q=c-3cX+qDmPfZC8_o_B8msQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Advice on key design  (Anton Gavazuk <antongavazuk@gmail.com>)
Re: Advice on key design  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
Re: Advice on key design  (Anton Gavazuk <antongavazuk@gmail.com>)
Список pgsql-sql
I have 2 tables, a parent (tbl_persons) and a child (tbl_languages_per_person) as follows (a language table is also involved):

------------------
tbl_persons
------------------
* per_id
* per_name
* per_address

--------------------------------------
tbl_languages_per_person
--------------------------------------
* lpp_person_id
* lpp_language_id
* lpp_id

As you can see, there is an obvious key in the child table which is "lpp_person_id + lpp_language_id", but I also need the field "lpp_id" as a unique key which is a field that contains a consecutive number of type serial. 

My question is: what should I configure as the primary key, "lpp_person_id + lpp_language_id" or "lpp_id"?
Is the role of a primary key different from that of a unique index?

With respect,
Jorge Maldonado






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

Предыдущее
От: ldrlj1
Дата:
Сообщение: Re: table constraint on two columns
Следующее
От: Anton Gavazuk
Дата:
Сообщение: Re: Advice on key design