Perl Monk, Perl Meditation | |
PerlMonks |
Re: Well Designed RDBMSby dga (Hermit) |
on Apr 07, 2003 at 14:56 UTC ( [id://248624]=note: print w/replies, xml ) | Need Help?? |
If you are only going to query the attributes rarely and want flexibility, personally I woud probably use a seperate table. The main table would have something to uniquely identify the blob and the other table would be like:
If I were going to have a lot of attributes or they were going to have long names, I would make a 3rd table with attribute_id and attribute_name then use the attribute_id in the attribute_table. Also a varchar field may be handy instead of text on the attribute name field if a combined table is used. When a lookup by attribute is wanted would be the only time this table is referenced and also it will be a fast lookup and much cheaper than a LIKE on a sizeable piece of text. The unique index will speed this up and prevent duplicate attributes of the same kind on a single blob.
This design doesn't require the attributes to be known at design time and they can be added or removed at any time and attributes which do not apply to a given blob use no space at all.
In Section
Seekers of Perl Wisdom
|
|