From: | Sebastian Böck <sebastianboeck(at)freenet(dot)de> |
---|---|
To: | Andreas <maps(dot)on(at)gmx(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: what about uniqueness of inherited primary keys |
Date: | 2003-12-29 17:36:27 |
Message-ID: | 3FF0661B.7020903@freenet.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Andreas wrote:
> Seastian Böck wrote:
>
>> for primary keys there is a simple (and at least working for me)
>> solution as long as you can use the SERIAL type for your primary
>> key.
>> [...]
>> Now the id column gets merged and you should have the desired
>> behaviour.
>>
>> If you want objects.id to get referenced by other tables you have
>> to work around with triggers and an extra table. For persons.id
>> everything is working fine.
>>
>> This solution (workaround) is only working as long you don't
>> insert id-values without updating the corresponding sequence.
>
>
>
> Hello Se(b)astian
> -- you left out the 'b' in your e-mail setup ;)
>
> right, your proposal does in a way behave like I wanted. Though the idea
> of integrity control by the db-server is still not there for parent
> id-colomns. Every user or application could mess up the primary key of
> the inherited table. That spoils a bit of the oo-approach, I fear.
I rechecked that and the conclusion is very simple:
it only works reliable if the id is autogenerated by the SERIAL type.
>
> It wouldn't be that bad, if the table contents weren't merged in SELECTs.
>
> Probaply one could do some trigger-magic to check the inserted id
> against an id-pool in another table.
> If one knew anything about triggers that is ... well ... miles to go
> before I sleep ...
For all other situations take a look at Oliver's mail.
Sebastian
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas | 2003-12-29 18:06:16 | Re: simple auto-updating timestamp ? |
Previous Message | Michael Glaesemann | 2003-12-29 17:22:42 | Re: Time varying referential integrity |