The database is in french
This is the People table
CREATE TABLE Resident
(
id_Resident
int(11) NOT NULL AUTO_INCREMENT,
nom_Resident
varchar(200) NOT NULL,
prenom_Resident
varchar(200) NOT NULL,
photo_Resident
varchar(20) DEFAULT NULL,
dateNaissance_Resident
date NOT NULL,
codeIncendie_Resident
int(11) NOT NULL,
PRIMARY KEY (id_Resident
)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
The room table
CREATE TABLE Chambre
(
id_Chambre
int(11) NOT NULL AUTO_INCREMENT,
id_Departement
int(11) NOT NULL,
nom_Chambre
varchar(50) NOT NULL,
description_Chambre
text NOT NULL,
prix_Chambre
int(11) NOT NULL,
actif_Chambre
tinyint(1) NOT NULL,
superficie_Chambre
int(11) NOT NULL,
plan_Chambre
varchar(20) DEFAULT NULL,
position_Chambre
varchar(20) DEFAULT NULL,
PRIMARY KEY (id_Chambre
),
KEY id_Departement
(id_Departement
),
CONSTRAINT Chambre_ibfk_1
FOREIGN KEY (id_Departement
) REFERENCES Departement
(id_Departement
)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
The intersection table between people & room
CREATE TABLE ResidentChambre
(
id_ResidentChambre
int(11) NOT NULL AUTO_INCREMENT,
dateArrive_ResidentChambre
date NOT NULL,
dateDepart_ResidentChambre
date DEFAULT NULL,
prix_ResidentChambre
int(11) NOT NULL,
bail_ResidentChambre
varchar(20) DEFAULT NULL,
dateFinBail_ResidentChambre
date DEFAULT NULL,
id_Chambre
int(11) NOT NULL,
id_Resident
int(11) NOT NULL,
PRIMARY KEY (id_ResidentChambre
),
KEY id_Resident
(id_Resident
),
KEY id_Chambre
(id_Chambre
),
CONSTRAINT ResidentChambre_ibfk_2
FOREIGN KEY (id_Chambre
) REFERENCES Chambre
(id_Chambre
),
CONSTRAINT ResidentChambre_ibfk_1
FOREIGN KEY (id_Resident
) REFERENCES Resident
(id_Resident
)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
The date that is important is dateDepart_ResidentChambre
And one more catch, if it’s null, it’s the one that got to get retrieved