From: | mark(at)mark(dot)mielke(dot)cc |
---|---|
To: | Gregory Stark <stark(at)enterprisedb(dot)com> |
Cc: | David Fetter <david(at)fetter(dot)org>, Edward Stanley <Edward(dot)Stanley(at)mcs(dot)vuw(dot)ac(dot)nz>, Richard Huxton <dev(at)archonet(dot)com>, Sean Utt <sean(at)strateja(dot)com>, Andrew Hammond <andrew(dot)george(dot)hammond(at)gmail(dot)com>, josh(at)agliodbs(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: My honours project - databases using dynamically attached entity-properties |
Date: | 2007-03-14 15:08:23 |
Message-ID: | 20070314150823.GA20578@mark.mielke.cc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Mar 14, 2007 at 02:28:03PM +0000, Gregory Stark wrote:
> "David Fetter" <david(at)fetter(dot)org> writes:
> > CREATE TABLE symptom (
> > symptom_id SERIAL PRIMARY KEY, /* See above. */
> > ...
> > );
> >
> > CREATE TABLE patient_presents_with (
> > patient_id INTEGER NOT NULL REFERENCES patient(patient_id),
> > symptom_id INTEGER NOT NULL REFERENCES symptom(symptom_id),
> > UNIQUE(patient_id, symptom_id)
> > );
>
> I'm just glad I don't have your doctor. I hope mine doesn't think symptoms are
> all boolean values.
Where is the boolean above? It is M:N, with each having whatever data
is required.
The issue I have with the above is that it seems unnecessarily
inefficient. Whenever mapping from a patient to a symptom, or a
symptom to a patient, it requires searching indexes for three tables.
Perhaps this would work well if there was heavy overlap of symptoms
for different patients. For the cases I have hit this problem,
however, there may be overlap, but it is not easy to detect, and even
if it was detected, we would end with some sort of garbage collection
requirements where symptoms are removed once all references to the
symptoms are removed.
The case most familiar to me, is a set of viewing preferences for web
pages. Some users specify no preferences, while others have dozens of
preferences. As I have no requirements to search for users with a
particular preference, I chose to solve this by packing many of the
preferences together into a TEXT field, and having the application
pack/unpack the data. I still have tables that map object id to
attribute/value, but they are used for the data that can require
longer queries. Without clustering the data, searching for a dozen
of these attributes requires either querying all attributes, where
the attributes could be scattered throughout the table, or querying
them one by one, which is worse.
If there was an efficient way to do this for both of my use cases,
I would be strongly tempted to use it. :-)
Cheers,
mark
--
mark(at)mielke(dot)cc / markm(at)ncf(dot)ca / markm(at)nortel(dot)com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-03-14 15:21:17 | Re: Daylight Saving Time question PostgreSQL 8.1.4 |
Previous Message | Alvaro Herrera | 2007-03-14 15:05:39 | Re: Daylight Saving Time question PostgreSQL 8.1.4 |