Schéma de la base de données
users
id (PK)
nom
prenom
telephone
latitude
longitude
email (unique)
password
created_at
updated_at
contacts
id (PK)
nom
prenom
telephone
email
notes
latitude
longitude
user_id (FK)
created_at
updated_at
Scripts SQL des tables
Table users
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(100) NOT NULL,
`prenom` varchar(100) NOT NULL,
`telephone` varchar(20) NOT NULL,
`latitude` double NOT NULL,
`longitude` double NOT NULL,
`email` varchar(100) NOT NULL UNIQUE,
`password` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);
Table contacts
CREATE TABLE `contacts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(100) NOT NULL,
`prenom` varchar(100) NOT NULL,
`telephone` varchar(20) NOT NULL,
`email` varchar(100) NULL,
`notes` text NULL,
`latitude` double NOT NULL,
`longitude` double NOT NULL,
`user_id` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
);