How can several different datatypes be saved in one table

Posted by poseidon on Stack Overflow See other posts from Stack Overflow or by poseidon
Published on 2010-05-15T17:18:24Z Indexed on 2010/05/15 17:24 UTC
Read the original article Hit count: 215

Filed under:
|
|

This is my situation: I am constructing an ad-like application in Django and Mysql. I am using a flexible-ad approach where we have:

a table with ad categories (several categories such as home, furniture, cars, etc.)

  • id_category
  • name

a table with details for the ad categories (home: area, squared meters. car: seats, color.)

  • id_detail
  • id_category (the categ the detail describes)
  • name
  • type (boolean, char, int, long, etc.)

the ad table (i am selling a house. i am selling a car.)

  • id_ad
  • id_category
  • text
  • date

a table where i plan to consolidate the details of the ads (home: A-area, 500 sq-meters. car: 5 seats, red.)

  • id_detail_ad
  • id_ad
  • id_detail
  • value

Is this possible? Can I have a table of details for all the ads, even if details include numbers, texts, booleans, etc? Or would I have to save them all as text and then interpret them via code accordingly? Please express your opinions. Thank you.

© Stack Overflow or respective owner

Related posts about django

Related posts about mysql