Re: Can a field be a primary key as well as a foreign key?
От | Jan Wieck |
---|---|
Тема | Re: Can a field be a primary key as well as a foreign key? |
Дата | |
Msg-id | 200203122145.g2CLjTU31327@saturn.janwieck.net обсуждение исходный текст |
Ответ на | Can a field be a primary key as well as a foreign key? (Andrew Snow <andrew@modulus.org>) |
Список | pgsql-general |
Andrew Snow wrote: > > > Can anyone see any problem with the following, practice? No problem at all. With that setup there can never be a subchild without the matching child, even if the parent exists. If a child is deleted, it's subchildren follow, no need to touch the parent. If that's the relationship of the data, go ahead. Jan > > > CREATE TABLE parent ( > foo SERIAL PRIMARY KEY > ); > > CREATE TABLE child ( > foo INTEGER PRIMARY KEY REFERENCES parent ON DELETE CASCADE, > bar TEXT > ); > > CREATE TABLE subchild ( > foo INTEGER PRIMARY KEY REFERENCES child ON DELETE CASCADE, > bar2 TEXT > ); > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
В списке pgsql-general по дате отправления: