Re: Employee modeling question - Mailing list pgsql-general

From Nelson Green
Subject Re: Employee modeling question
Date
Msg-id CAGo-KZkYAZygBkJug3vsQJqLvSRmyC9typP7uq0g=hrwEYWMFQ@mail.gmail.com
Whole thread Raw
In response to Re: Employee modeling question  (Robin <robinstc@live.co.uk>)
Responses Re: Employee modeling question  (John McKown <john.archie.mckown@gmail.com>)
List pgsql-general
> I could store the department and business attributes with the
> employee, but without proper constraints the referenced department
> could conceivably not correspond to the referenced business. Or I
> could ensure that all businesses have at least one department,
> defaulting to the business when the business has no department, but
> then I'd be storing duplicate data. The other alternative I've come up
> with is an exclusive constraint where the employee instance can only
> reference a department or a business, but not both.
>
> None of these solutions seems ideal, although the exclusivity solution
> seems like it would work the best, and I have had to create
> exclusivity constraints before. So, am I missing a more obvious
> solution, or am I even on track here?

I’ve found this « Universal Person and Organization Data Model » very useful to understand complex questions like that: http://www.tdan.com/view-articles/5014

Hope this helps,
François Beausoleil

 
Thanks François. This is pretty generic stuff, but my first reading has got me thinking that I should at least pick up some ideas from it. I will give it a go. And I've got a new web site that I've now known about before, so thanks for that as well.

Regards,
Nelson

I strongly suggest you read the writings of Joe Celko, he has been addressing this kind of problem for decades. Ultimately, it is very important not to confuse behaviour with entities (yes employment is behavioural)

Cheers

Thanks Robin. Ironically enough, our little local library has three books by Joe Celko, so looks like I may have a weekend of reading ahead of me.

Nelson

pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: Exists subquery in an update ignores the effects of the update itself
Next
From: Kevin Grittner
Date:
Subject: Re: Merge requirements between offline clients and central database