Wolfgang Keller-2 wrote
> It hit me today that a 1..* relationship can't be implemented just by a
> single foreign key constraint. I must have been sleeping very deeply not
> to notice this.
>
> E.g. there is a table "list" and another table "list_item" and the
> relationship can be described as "every list has at least one
> list_item" (and every list_item can only be part of one list, but
> this is trivial).
Change the cardinality to "0..*" ?
If you want to enforce a view of the data the ensures "1..*" (for list) then
create a view of "list" where only those entries with values in "list_item"
are shown.
Alternately you might simply add a counter column to the list table and use
triggers to increment/decrement the "item_count".
David J.
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Proper-solution-for-1-relationship-tp5753384p5753392.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.