0

I have a form with 80 checkboxes.. Its a options form for car.. For example

Colour: black , red , white , yellow etc.. How should i design my database for many options?

should i create 80 column in table? or use implode() and save in a one column or multiple rows? but when i need i should update it...

Car_id |  black | red | white | yellow  |..... | option80 |
1            true     true     

how should i do ? Thank you for your help

2
  • You should normalze your database tables. Commented Jan 17, 2013 at 9:19
  • 1
    A table for car that has a column linked to a table called color, this way 1 column has a relationship with another table and so on. Commented Jan 17, 2013 at 9:21

2 Answers 2

2

Check out normalization. That might help.

Anyway, to help you get on your way, here's a basic setup for that.

+-----TABLE CAR------+
ID
NAME

+-----TABLE COLOR------+
ID
COLOR

+-----TABLE CAR_COLOR------+
CAR_ID
COLOR_ID

This makes sure you have a link table between CAR and COLOR

Hope this was helpful

Sign up to request clarification or add additional context in comments.

2 Comments

how can i update it ? maybe there are 40 options checked? its gonna be car_id 1 , color_id 1 | car_id 1 , color_id 2
exactly, that's how the link table is used.
0

If you plan to do in the future selection of the item by color, then it is better to create related tables:

table of cars (car_id, car_name)

table of colors (color_id, color_name)

table of relation colors and cars (car_id, color_id)

(sql - join)

And if you plan to just use as a characteristic of the car, then one cell with all the flowers separated "|" and when you create insert in the database use implode(), and select from the database explode()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.