Jump to content

Various number of attributes


Mastodont

Recommended Posts

What route is best to go if I need design tables for entities with arbitrary numbers of attributes? I know that is called EAV (entity - attribute - value) and tried a Google, but missed answer for actual table design.

 

If we have arbitrary attributes with various data types, there are three ways to go:

 

  1. item_id - attribute - value // one table, values with different data types in third column

  2. item_id - attribute - value // one table for each data type

  3. item_id - attribute - string - integer - float - date ... //one column for each data type (I see this in BEA WebLogic)

 

First option is terrible. But the others look fine (?). Downsides of second choice include complicated selects and writing, third choice leads to "Swiss cheese" table.

 

Has anybody experiences with EAV?

Link to comment
Share on other sites

I'd probably go with #2. Makes most sense to me. #1 also might work. MySQL has several functions, that help in type juggling. #3 has the least appeal to me. Having table filled mostly with nulls is just too inefficient...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.