That's right, I'm not sure how to do this.
tb_Customer(id_Customer INTEGER [PK], nm_Customer VARCHAR, cpf_cnpj NUMERIC)
dm_address_type(cd_address_type CHAR(1) [PK], ds_address_type VARCHAR)
tb_customer_address(id_customer [PFK], cd_address_type CHAR(1)[PFK], street VARCHAR, lot INTEGEER, references VARCHAR, zip_code VARCHAR)
SELECT * FROM dm_address_type
cd_address_type: R , C , O
ds_address_type: Residencial, Comercial, Outros
My question is as follows, to register the client 'JOIN' would the following SQL?:
Joãozinho Silva - 888.777.666-55
Residential Address: Rua das Flores, 1. Zip Code: 01234-567 Business Address: Rua das Pedras, 100 Conjunto 200. Zip / Postal Code: 01234-567
INSERT INTO tb_Customer(nm_customer, cpf_cnpj) VALUES ("Jãozinho Silva", "888.777.666-55")
SET @ic_Customer = LAST_INSERT_ID()
INSERT INTO tb_customer_address(street, lot, references, zip_code, id_customer, cd_address_type) values ('Rua das Flores', '1', 'references', 01234-567', @id_Customer, 'R')
INSERT INTO tb_customer_address(street, lot, references, zip_code, id_customer, cd_address_type) values ('Rua das Pedras', '100 Conjunt 200', 'references', 01234-567', @id_Customer, 'C')
And another question is how many different addresses can I register for each customer? How many needed, right?
Vlww staff. Hugs!