I am making a database that houses public transport data and I have a small lack of focus
this is my SQL:
CREATE TABLE IF NOT EXISTS 'prueba'.'lineas' (
'idlineas' INT NOT NULL AUTO_INCREMENT,
'numero' INT NOT NULL,
PRIMARY KEY ('idlineas'));
CREATE TABLE IF NOT EXISTS 'prueba'.'trayectos' (
'idtrayectos' INT NOT NULL AUTO_INCREMENT,
'ramal' VARCHAR(30) NOT NULL,
'itinerario' VARCHAR(500) NOT NULL,
PRIMARY KEY ('idtrayectos'));
CREATE TABLE IF NOT EXISTS 'prueba'.'tipo_buses' (
'idtipo_buses' INT NOT NULL AUTO_INCREMENT,
'descripcion' VARCHAR(15) NOT NULL,
PRIMARY KEY ('idtipo_buses'));
CREATE TABLE IF NOT EXISTS 'prueba'.'empresas' (
'idempresas' INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY ('idempresas'));
CREATE TABLE IF NOT EXISTS 'prueba'.'operador' (
'idoperador' INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY ('idoperador'));
CREATE TABLE IF NOT EXISTS 'prueba'.'lectores' (
'idlectores' INT NOT NULL AUTO_INCREMENT,
'serie' VARCHAR(20) NOT NULL,
PRIMARY KEY ('idlectores', 'serie'));
CREATE TABLE IF NOT EXISTS 'prueba'.'buses' (
'idbuses' INT NOT NULL AUTO_INCREMENT,
'idtipo_buses' INT NOT NULL,
'idlineas' INT NOT NULL,
'idtrayectos' INT NOT NULL,
'idempresas' INT NOT NULL,
'idoperador' INT NOT NULL,
'idlectores' INT NOT NULL,
'serie' VARCHAR(20) NOT NULL,
'chapa' VARCHAR(12) NOT NULL,
'coche_numero' INT NOT NULL,
'observaciones' VARCHAR(45) NULL,
PRIMARY KEY ('idbuses', 'idtipo_buses', 'idlineas', 'idtrayectos',
'idempresas', 'idoperador', 'idlectores', 'serie'),
CONSTRAINT 'fk_tipo_buses_tipo_buses1'
FOREIGN KEY ('idtipo_buses')
REFERENCES 'prueba'.'tipo_buses' ('idtipo_buses'),
CONSTRAINT 'fk_lineas_lineas1'
FOREIGN KEY ('idlineas')
REFERENCES 'prueba'.'lineas' ('idlineas'),
CONSTRAINT 'fk_trayectos_trayectos1'
FOREIGN KEY ('idtrayectos')
REFERENCES 'prueba'.'trayectos' ('idtrayectos'),
CONSTRAINT 'fk_empresas_empresas1'
FOREIGN KEY ('idempresas')
REFERENCES 'prueba'.'empresas' ('idempresas'),
CONSTRAINT 'fk_lectores_lectores1'
FOREIGN KEY ('idlectores' , 'serie')
REFERENCES 'prueba'.'lectores' ('idlectores' , 'serie'));
As you can see I put as unique candidates in the table buses to sheet metal and car number so that they do not repeat, but when inserting the data I am not able to make both the idlectores or id operator do not repeat, that is, in the bus table can exist 2 buses that have the same operator to the same reader and that in practice should not be like that and I am not able to find where I can correct that, I think it is a problem of foreign keys, could you help me please
Update: Make the changes that advised me, so I leave the table but again I have the same problem 2 different buses that have the same operator and same reader ..