Search Postgresql Archives

Composite types for composite primary/foreign keys?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

for some reason, I couldn't get an answer on the novice-list, so if this is the wrong place to ask or if it's just in the manual, excuse me and just drop me a hint to the place where I have to look for it...

As far as I understand from the (excellent, btw.) PostgreSQL documentation, inheritance of primary or foreign keys is not (yet?) supported. That's a pity, because it makes inheritance essentially useless in my case: A database schema with 300-400 tables and a strongly hierarchically structured identification schema using composite primary keys. And also bulkloads of corresponding foreign keys criss-crossing all over the schema.

But I am pathetically lazy >;->, so I ld like to save keystrokes and thus I had the (maybe pathetic)idea to use composite types for the composite primary (and foreign) keys. No luck again, it seems to me, as according to the documentation: "since no constraints are associated with a composite type, the constraints shown in the table definition do not apply to values of the composite type outside the table".

I'm sorry, but I'm apparently too dump to actually figure out myself whether this means that I can use a single composite type column as a primary / foreign key or whether not...?

Obviously I can't define the constraint within the type definition ("no
constraints (such as NOT NULL) can presently be included"), but if I define the (NOT NULL and PRIMARY/FOREIGN KEY) constraint on the single (composite) key column in the table definition, will it work as I would expect it from a composite primary/foreign key? If so, this would be really great. Because it would make the whole schema much more readable for a clueless moron like me. ;-) And it would also simplify mapping it to a logical model in Python quite a bit.

TIA,

Sincerely,

Wolfgang Keller


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux