I am carrying out a project of industrial warehouses and warehouses but I have a doubt when making the registration of contracts. When I register a contract, I occupy a warehouse that is identified by its id. The problem comes when I register 2 contracts in a warehouse at the same time. I want to avoid this and they suggested using triggers or stored procedures. I would like to know your opinion and if you can give me an idea of how it would be.
this is the contract table
create table Contratos (
ID_BN int not null,
ID_Empresa int not null,
ID_Contrato int not null AUTO_INCREMENT,
ID_Empleado int not null,
Fecha_Contrato date not null,
Estatus_C varchar (15) not null,
PRIMARY KEY (ID_Contrato));
and it is that of warehouses and ships
create table Bodenave (
ID_BN int not null AUTO_INCREMENT,
Nombre_BN varchar(30) not null,
Tipo varchar (30) not null,
Localizacion varchar (50) not null,
Precio_renta decimal (7,2) not null,
Estatus_BN varchar (15) not null,
Metros_ancho decimal (4,2) not null,
Metros_largo decimal (4,2) not null,
Oficinas varchar (30) not null,
PRIMARY KEY (ID_BN));
I would appreciate your help