I have those doubts in SQL .. It is a language that is not so strict and runs despite the different ways of writing it .. What exactly is the difference between CREATE SCHEMA and CREATE DATEBASE when I started to see the code generated by Workbech this he works with SCHEMA and I really do have something that word has marred me .. all my short studio life of sql had been DATABASE: S
On the other hand taking advantage of the question .. also the Workbench makes use of the CONSTRAINT in front of the FOREIGNKEY
Here is an example of code generated by Workbench
CREATE TABLE IF NOT EXISTS 'tallermecanico_hd'.'e_vehiculos' (
'placa' INT NOT NULL,
'marca' VARCHAR(25) NULL,
'modelo' VARCHAR(25) NULL,
'anio' VARCHAR(4) NULL,
'observ' VARCHAR(255) NULL,
'serial' VARCHAR(25) NULL,
'color' VARCHAR(25) NULL,
'puertas' INT,
'motor' VARCHAR(25) NULL,
'transmision' VARCHAR(25) NULL,
//<<<aqui yo colocaria el campo foraneo cedula_c pero workbench no lo hizo<<<
PRIMARY KEY ('placa'),
CONSTRAINT 'cedula_c'
FOREIGN KEY ()
REFERENCES 'tallermecanico_hd'.'c_clientes' ()
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
I was used to the Foreignkey just place like this:
FOREINGN KEY(cedula_c)REFERENCES c_clientes
and if it works the same but what is the difference D: what does the CONSTRAINT do ??? In addition, the Workbench uses the database name.tablename, besides, I do not put anything in the parentheses of references and it does not create the foreign field cedula_c
How do I look for the subject of the points ... [db]. [table] as it is called, is that point the same as putting FROM or something similar? that has a name to look well for that topic that nobody gave it to me. <