0
I am with a page that collects information from the sales team, with customer data, competition data, etc. Follow code:
CREATE TABLE dados_relatorio(
id int(4) unsigned NOT NULL AUTO_INCREMENT,
codigo int(10) unsigned NOT NULL,
data_1 date NOT NULL,
vendedor varchar(45) NOT NULL,
supervisor varchar(20) NOT NULL,
cidade varchar(50) NOT NULL,
uf varchar(5) NOT NULL,
razao varchar(40) NOT NULL,
ramo varchar(35) NOT NULL,
posicionamento varchar(6) NOT NULL,
limpeza varchar(3) NOT NULL,
layout varchar(3) NOT NULL,
visibilidade varchar(3) NOT NULL,
visibilidade_i varchar(3) NOT NULL,
materiais varchar(3) NOT NULL,
equipamento smallint(3) unsigned NOT NULL,
qtd_equipamento smallint(3) unsigned NOT NULL,
tabela varchar(8) NOT NULL,
cat_real smallint(3) unsigned NOT NULL,
cat_premium smallint(3) unsigned NOT NULL,
cat_paleta smallint(3) unsigned NOT NULL,
cat_frutas smallint(3) unsigned NOT NULL,
cat_infantil smallint(3) unsigned NOT NULL,
cat_acai smallint(3) unsigned NOT NULL,
cat_mono smallint(3) unsigned NOT NULL,
cat_outro smallint(3) unsigned NOT NULL,
dividido varchar(9) NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
It turns out that management wants to be linked to the mileage of the day, but these data should come in the following format: The seller "opens" the day in the system, inserts the mileage, after that, the system releases to receive the data and enter in the database. At the end of the day, "the day closes" with the final mileage. Today, after the seller’s login, he inserts the date of the visit, and collects the data. I thought I’d create another table to enter the dates and mileage, and then make some sort of parole, but I thought it was a long approach to getting to that goal.
Is there any "more" viable alternative? Because each seller will have to make this "opening" of the day with the initial mileage and close the day with the final mileage, and he can only enter the data if this opening is performed, and consequently, the new day will also require the closure of the last.... If that’s the best approach, I’ll jump in, but if there’s any other one you think better, I’d be grateful.
Thank you.
*I thought of creating another table to enter the dates and mileage" It seems to me, with the data you have in question, the best opiation, a table that has the date and FK with seller, which can have two columns
KMAbertura
andKMFechamento
. This will make you need an INSERT and then an UPDATE, but it has an advantage, when logging in check if there is a line in this table for the seller/date, if you do not ask, if you already have it, let us send data. If you want more details let me know that I can put in a reply– Ricardo Pontual
Hey @Ricardopunctual. I get it. If you can add details, I’d appreciate it. I’d be grateful if you could explain how FK would work in this case. I understand that it depends on the PK of the other table, but the dynamics confess that I did not take 100%. Thank you.
– Leonardo - Paletitas