Re: Inheritance
От | Oliver Elphick |
---|---|
Тема | Re: Inheritance |
Дата | |
Msg-id | 200007311234.e6VCY1A30789@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | Inheritance (Ian Turner <vectro@pipeline.com>) |
Список | pgsql-general |
Jan Wieck wrote: >Oliver Elphick wrote: >> Jan Wieck wrote: >> >> Yes, but what about referential integrity? Can I have a table column >> >> reference a column from Entities*? In my experimentation, this is not > the >> >> case. >> > >> > Referential integrity doesn't work with inheritance, and will >> > not in 7.1. >> > >> > It isn't possible to put a unique constraint on a column of >> > Entities* (AFAIK). So that a SELECT pkey FROM Entities will >> > never return any duplicates? The RI implementation of >> > PostgreSQL doesn't insist on such a unique constraint to >> > exist up to now, but it is required by the SQL specs and thus >> > we'll do so someday. >> >> The corollary of using RI on an inheritance tree is that there should be a >> unique index on the primary keys of the whole tree. If constraints could >be >> inherited, this would become available. > > The UNIQUE constraint is implemented as a UNIQUE INDEX in > PostgreSQL. And exactly what you say: "ONE" index on the > whole tree would be required to do it. > > What you're asking for is index inheritance instead of RI > trigger inheritance first - right? So that an index will > contain tuples for all the keys present in it's tables > subclasses, for beeing able to detect a dupkey. Yes, at least as an option. In many cases of inheritance the id should be unique in the whole tree, and so a unique index on the whole tree is needed. If this index is present, the tree can be available for RI use. There may be cases where a unique index is not wanted, but in that case the cost is that RI becomes unavailable except on individual tables. -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47 GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Have not I commanded thee? Be strong and of a good courage; be not afraid, neither be thou dismayed; for the LORD thy God is with thee whithersoever thou goest." Joshua 1:9
В списке pgsql-general по дате отправления: