tags:

views:

40

answers:

2

Hi, I have a project that makes me confused. I am creating a 2nd hand sale car page for a saler. I have display and edit pages. In edit pages, user will insert a sale car record or edit an existing record. I mean Such a table:

RecordID CARNAME Model Year KM PRICE

(This Part is ok, easy; but details of car will be showed and edited with checkboxes and also features must be editable)),

(Checkbox1) Airbag (Checkbox2) Sunroof (Checkbox 3) Xenon lamb etc.

I think I must Create that tables: Cars, Marks, Models, Features(includes checkboxes)... But How will i get data from features; how will i know which check is checked or not and How will i know , which car has which features?

+1  A: 

What you need is a table which lists features indexed by an integer:

FEATURES:

featurecode   feature
1             airbag
2             sunroof
3             headlights
.....

Then you have a table that lists features per REcordid with recordid as a foreign key:

RecordIDFeatures:

RecordID     Featurecode
23032        1
23032        2
23034        3
........

Then to get features per car you do:

selectt f.feature, s.car from features f, salesCarRecord s,RecordIDFeatures r where  (r.recordid = s.recordid) and (r.featurecode = f.featurecode)
ennuikiller
+1  A: 

You need a Features table and then a Features_Car junction table

Features Table
--------------

FeatureId | Name
----------------
1         | Sunroof
2         | Air Conditioning
3         | Power Steering

Features_Car Table
--------------

FeatureId | RecordId
----------------
1         | 1
2         | 1
3         | 1
1         | 2
2         | 2
1         | 3
3         | 3

Updating based on checkboxes in the UI will be straightforward, just INSERT or DELETE values from the junction table based on which checkboxes are checked or unchecked, respectively

Russ Cam
I think both answers are same and true, Thank you friends...
Mehmet Kaleli