If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Single columns with multiple data types. possible ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-07, 18:28
TkNeo TkNeo is offline
Registered User
 
Join Date: Feb 2007
Posts: 5
Single columns with multiple data types. possible ?

I want to have a table with 2 columns. Key and Value. The value can be of 3 different data types (date, double, string)....

Now in my front end applications which access the table i want to receive the data in the correct data types. i.e. date as date, string as string and so on....

One way i thought about is that i create 3 tables. so depending on what table i am selecting the value from i will do the CAST in the select statement. It however doesnt seems to be a very clean solution. Any other idea i think of doesnt seem to be normalized well. Can anyone share their thoughts on this ?
Reply With Quote
  #2 (permalink)  
Old 02-08-07, 18:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
no, not possible

and 3 separate tables is an improvement but still a poor design

is this what you are trying to do? (hint: don't) --

Dave's guide to the EAV

One True Lookup Table by Joe Celko

OTLT and EAV: the two big design mistakes all beginners make

Lookup Table Madness

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-11-07, 12:22
TkNeo TkNeo is offline
Registered User
 
Join Date: Feb 2007
Posts: 5
Thanks a lot for the links. Def good info. I had not thought everything through but i was expecting major issues in querying the database with such design. The only reason for using this is that i thought adding of columns can be done on the fly. Now clearly all the links give the verdict to not use EAV correct ? However none of them compare the two design on the task of adding a new attribute column ? How would it affect my front end code and everything ? Would EAV still be a bad design ?
Reply With Quote
  #4 (permalink)  
Old 02-12-07, 16:18
TkNeo TkNeo is offline
Registered User
 
Join Date: Feb 2007
Posts: 5
Also unfortunately its my boss who came up with the EAV idea so i think i would have to go with that one. I did send him those links but he doesn't like the COMPACT design as the code will change if any columns are added/removed....
Reply With Quote
  #5 (permalink)  
Old 02-18-07, 12:16
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Maybe your boss would like The Associative Model of Data. Not that I'm recommending it: it looks like EAV on steroids to me, and I wrote one of the anti-EAV articles Rudy listed above!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On