I'm doing a section on my website called "My Ideal Surfboard", the user enters their data (weight, height, etc.), a comparison is made in database (join
) and is returned to the ideal types of surfboard user according to his profile.
I have a table with the reference of all sizes and types of surfboard according to height, weight and user experience.
I'm doing the following:
Divided into two tables:
- Table USER
obviously stores user data (experience, height and weight);
- Table SURFBOARD
possesses the reference values (type, size, weight and litres) on each surfboardd according to experience, weight, height of the user.
-> I liken the table USER
to the table SURFBOARD
and return to the user the ideal model. How to do this?
At first I thought putting the same fields both in the table USER
as in the table SURFBOARD
make a inner join
and have the data you want.
However, the both tables would duplicate values.
`dados_usuario` `prancha`
height2 weight2
height2 weight2
height2 weight2
height1 weight2
height1 weight2
height1 weight2
I compare and I display...
I believe that this is not a good practice and not the best way to do this. I know there are other methods to do this.
The issue is, how best way to compare these data?
How to identify which line is compatible with the data that the user will enter?
MY DATABASE:
CREATE TABLE USER(
usuario INT NOT NULL AUTO_INCREMENT,
nome VARCHAR(150) not null,
email VARCHAR(50) not null,
estilo VARCHAR(14) not null,
exp VARCHAR(13) not null,
altura VARCHAR(12) not null,
peso VARCHAR(9) not null,
PRIMARY KEY(usuario)
);
CREATE TABLE SUFBOARD(
prancha_pri INT NOT NULL AUTO_INCREMENT,
tipo_prancha VARCHAR(9) NOT NULL,
tamanho_prancha VARCHAR(9) not null,
meio_prancha VARCHAR(12) not null,
litragem_prancha VARCHAR(8) not null,
PRIMARY KEY (prancha_pri)
);
INSERTING DATA IN TABLE 'USER':
INSERT INTO EXPERIENCIA VALUES (NULL, 'joao', 'a@a.com', 'Surf', 'INICIANTE', '<1,60m', '>90kg');
INSERT INTO EXPERIENCIA VALUES (NULL, 'john', 'b@b.com', 'StandUP Paddle', 'INTERMEDIARIO', '1,81 - 1,90m', '81 - 90kg');
INSERT INTO EXPERIENCIA VALUES (NULL, 'carl', 'c@c.com', 'Surf', 'AVANÇADO', '>1,90m', '71 - 80kg');
INSERTING DATA IN TABLE SURFBOARD
:
INSERT INTO PRANCHA VALUES (1, 'FUN', '8', '21 polegadas', '43L');
INSERT INTO PRANCHA VALUES (2, 'FUN', '8.8', '21 polegadas', '43L');
INSERT INTO PRANCHA VALUES (3, 'LONGBOARD', '9.2', '21 polegadas', '55L');
INSERT INTO PRANCHA VALUES (4, 'PRANCHA', '5.5 a 5.8', '20 polegadas', '30L');
INSERT INTO PRANCHA VALUES (5, 'PRANCHA', '5.5 a 5.10', '20 polegadas', '30L');
INSERT INTO PRANCHA VALUES (6, 'PRANCHA', '5.9 a 6.0', '21 polegadas', '32L');
INSERT INTO PRANCHA VALUES (7, 'PRANCHA', '6.0 a 6.4', '21 polegadas', '34L');
INSERT INTO PRANCHA VALUES (8, 'PRANCHA', '5.10 a 6.4', '20 polegadas', '30L');
INSERT INTO PRANCHA VALUES (9, 'PRANCHA', '5.10 a 6.4', '20 polegadas', '32L');
INSERT INTO PRANCHA VALUES (10, 'PRANCHA', '6.2 a 6.6', '21 polegadas', '32L');
INSERT INTO PRANCHA VALUES (11, 'PRANCHA', '6.4 a 6.8', '21 polegadas', '34L');
INSERT INTO PRANCHA VALUES (12, 'PRANCHA', '6.2 a 6.6', '20 polegadas', '30L');
INSERT INTO PRANCHA VALUES (13, 'PRANCHA', '6.2 a 6.6', '21 polegadas', '30L');
INSERT INTO PRANCHA VALUES (14, 'PRANCHA', '6.2 a 6.6', '21 polegadas', '34L');
INSERT INTO PRANCHA VALUES (15, 'PRANCHA', '6.2 a 6.6', '21 polegadas', '36L');
INSERT INTO PRANCHA VALUES (16, 'PRANCHA', '6.2 a 6.6', '21 polegadas', '38L');
INSERT INTO PRANCHA VALUES (17, 'PRANCHA', '6.2 a 7.0', '21 polegadas', '34L');
INSERT INTO PRANCHA VALUES (18, 'PRANCHA', '6.2 a 7.0', '21 polegadas', '38L');
INSERT INTO PRANCHA VALUES (19, 'PRANCHA', '5.5 a 5.8', '18 polegadas', '23L');
INSERT INTO PRANCHA VALUES (20, 'PRANCHA', '5.8 a 5.10', '18 polegadas', '24L');
INSERT INTO PRANCHA VALUES (21, 'PRANCHA', '5.10', '18 polegadas', '27L');
INSERT INTO PRANCHA VALUES (22, 'PRANCHA', '6.0 a 6.2', '19 polegadas', '28L');
INSERT INTO PRANCHA VALUES (23, 'PRANCHA', '6.0 a 6.2', '19 polegadas', '29 a 31L');
INSERT INTO PRANCHA VALUES (24, 'PRANCHA', '5.10 a 6.0', '19 polegadas', '24L');
INSERT INTO PRANCHA VALUES (25, 'PRANCHA', '5.10', '19 polegadas', '26L');
INSERT INTO PRANCHA VALUES (26, 'PRANCHA', '6.0', '19 polegadas', '27L');
INSERT INTO PRANCHA VALUES (27, 'PRANCHA', '6.0', '19 polegadas', '29L');
INSERT INTO PRANCHA VALUES (28, 'PRANCHA', '6.2', '20 polegadas', '30 a 31L');
INSERT INTO PRANCHA VALUES (29, 'PRANCHA', '6.0', '19 polegadas', '25L');
INSERT INTO PRANCHA VALUES (30, 'PRANCHA', '6.0', '19 polegadas', '28L');
INSERT INTO PRANCHA VALUES (31, 'PRANCHA', '6.0', '19 polegadas', '30L');
INSERT INTO PRANCHA VALUES (32, 'PRANCHA', '6.0 a 6.2', '20 polegadas', '30 a 31L');
INSERT INTO PRANCHA VALUES (33, 'PRANCHA', '5.11', '19 polegadas', '26L');
INSERT INTO PRANCHA VALUES (34, 'PRANCHA', '5.11', '19 polegadas', '28L');
INSERT INTO PRANCHA VALUES (35, 'PRANCHA', '6.0', '20 polegadas', '29L');
INSERT INTO PRANCHA VALUES (36, 'PRANCHA', '6.1', '20 polegadas', '30L');
INSERT INTO PRANCHA VALUES (37, 'PRANCHA', '6.1 a 6.6', '20 polegadas', '30 a 31L');
INSERT INTO PRANCHA VALUES (38, 'PRANCHA', '6.1', '19 polegadas', '27L');
INSERT INTO PRANCHA VALUES (39, 'PRANCHA', '6.1', '19 polegadas', '28L');
INSERT INTO PRANCHA VALUES (40, 'PRANCHA', '6.1 a 6.3', '20 polegadas', '29L');
INSERT INTO PRANCHA VALUES (41, 'PRANCHA', '6.1 a 6.4', '20 polegadas', '31L');
INSERT INTO PRANCHA VALUES (42, 'PRANCHA', '6.2 a 6.6', '20 polegadas', '31L');
In my form, visually they are all of height and weight exact values. However, the value of the fields are the values of my reference table:
HEIGHT:
<option value="1,71 - 1,80m">1.71m</option>
<option value="1,71 - 1,80m">1.72m</option>
<option value="1,71 - 1,80m">1.73m</option>
<option value="1,71 - 1,80m">1.74m</option>
<option value="1,71 - 1,80m">1.75m</option>
<option value="1,71 - 1,80m">1.76m</option>
WEIGHT:
<option value="81 - 90kg">88Kg</option>
<option value="81 - 90kg">89Kg</option>
<option value="81 - 90kg">90Kg</option>
<option value=">90kg">91Kg</option>
<option value=">90kg">92Kg</option>
<option value=">90kg">93Kg</option>
<option value=">90kg">94Kg</option>
Aucun commentaire:
Enregistrer un commentaire