Save Characteristics in DB [closed]

4

I'm starting to work with PHP, MYSQL now and I've had a question.

I am developing a classified website, the same will have categories of vehicles, real estate, electronics, etc ...

My question is as follows, the guy selects car for example, car has numerous features, such as a cell phone, an apartment, etc ... how can I record these features in BD?

Create a table for each type? (car, truck, apartment, cell phone ...), right?

Can anyone give me a direction?

Remembering that all features are selected in a checkbox based on availability and ad type.

Follow div with checkbox

<label class="col-sm-2 control-label">Características</label>
                <div class="col-sm-9">
                  <div class="row">
                    <div class="col-sm-3"><input type="checkbox"> Air-Bar </div>
                    <div class="col-sm-3"><input type="checkbox"> Ar-Condicionado </div>
                    <div class="col-sm-3"><input type="checkbox"> Vidros Elétricos </div>
                  </div>
                  <div class="row">
                    <div class="col-sm-3"><input type="checkbox"> Flash </div>
                    <div class="col-sm-3"><input type="checkbox"> Câmera Frontal </div>
                    <div class="col-sm-3"><input type="checkbox"> GPS </div>
                  </div>
                  <div class="row">
                    <div class="col-sm-3"><input type="checkbox"> Tecnologia NFC </div>
                    <div class="col-sm-3"><input type="checkbox"> Detecção Facial </div>
                    <div class="col-sm-3"><input type="checkbox"> Dual Chip </div>
                  </div>
                  <div class="row">
                    <div class="col-sm-3"><input type="checkbox"> Biometria </div>
                    <div class="col-sm-3"><input type="checkbox"> HDR </div>
                    <div class="col-sm-3"><input type="checkbox"> Extensão para Cartão de Memória </div>
                  </div>
                </div>

Thank you all.

    
asked by anonymous 03.03.2015 / 01:46

2 answers

0

Hello, as other users have said, you can do in a variety of ways, in my opinion, I kept in a string, but in code form, 0 and 1, for example: 101 -> Air- Conditioner: no, Electric Windows: yes, etc, but as they said you can do it in many ways! good luck

    
03.03.2015 / 21:07
0

friend what you will get there is a relationship of many to many, ie, N to N.

What you should do is: create a table called "vehicle", another called "characteristic" and another called "veiculo_caracteristica" that will have the following columns:

id_veiculo;
id_caracteristica;

So a characteristic can be of several vehicles and a vehicle can have several characteristics.

Any question just ask about the relationship N to N that you will understand better!

P.S .: I used vehicle as an example but serves to anyone you want to implement: apartment, mobile and etc ...

    
04.06.2015 / 04:07