A searchable datastructure for represeting attributes?
Date: Wed, 27 Feb 2002 11:16:15 -0500
Message-ID: <3C7D064F.C304F9D4_at_thankyou.very_much>
THE QUESTION: Is there any good datastructure for representing
attributes which has the advantages of approach_1 and the search and
sort convenience of approach_2 below? Seems like a problem many people
would
1)
(keys could be normalized of course but I skip that for this example)
2)
objectid phone addr
The first approach has several advantages
have run into.
objectid key value
78 phone 555-1212
78 addr Main Street
79 phone 222-2222
79 addr Green Street
78 555-1212 Main Street
79 222-2222 Green Street
- It is flexible. That is you do not need to change the schema to add new attribute types.
- It is normalized in a sense that if an attribute does not have a value you can represent it by its absense in the table istead of duplicating NULL in every feild that does not have a value. In my case this is actually a critical thing because there are a lot of attributes whose values are not set.
- very slow when table is large
- you need to do a self join for every attribute in the AND-ed expression.
- If you want to sort by an attribute other than the search key you need to self join yet again.
By contrast with approach 2 all these problems go away:
select id from mytable where phone='555-1212' and addr='Main Street' order by some_field
Thank you so much for your response
Dre Received on Wed Feb 27 2002 - 17:16:15 CET