Re: Three table database - period (?)
Date: 30 Jan 2001 17:01:56 GMT
Message-ID: <956s24$3vb$1_at_news.tue.nl>
Jens wrote:
> Hi
>
> I have been wondering about the merits / pitfalls of the
> following table structure:
>
> Entity(ID)
>
> EntityAttribute(EntityID, AttributeID)
>
> Attribute(ID, Type, EntityID, Number, String, Date, Blob,
> ...)
>
> This describes an entity that has some attributes linked to
> it through the EntityAttribute table. The attribute table's
> Type field describes which of the attribute fields is
> actually used.
>
> I don't seem to need any more tables as I can describe
> anything with these three (or can I?). I'm also concerned
> about speed and space consumption but the flexibility this
> seems to give me is tempting.
>
> You may even have a name for this 'little monster' :)
Entity(ID)
EntityAttribute(EntityID, Name, AttributeID, Type) Pr.Key: EntitiyID, Name
NumberAttr(ID, Number)
Pr.Key: ID
StringAttr(ID, String)
Pr.Key: ID
DateAttr(ID, Date)
Pr.Key: ID
...
That saves some space (no NULLs) and you can add new types of attributes without changing the existing tables.
-- Jan HiddersReceived on Tue Jan 30 2001 - 18:01:56 CET