Before we start coding the login.php
page, we need to add two tables to the sakila
database. These two tables are going to represent the users and also the groups that the users can belong to. In our project, a user can belong to only one group, as shown in the following screenshot:
First, we are going to create the Groups
table:
CREATE TABLE IF NOT EXISTS `sakila`.`Groups` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(45) NOT NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB;
Then, we are going to create the User
table containing the indexes, and will also create the foreign key to the Groups
table:
CREATE TABLE IF NOT EXISTS `sakila`.`User` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(100) NOT NULL , `userName` VARCHAR(20) NOT NULL , `password` VARCHAR(35) NOT NULL , `email` VARCHAR(100) NOT NULL , `picture` VARCHAR(100) NULL , `Group_id` INT NOT NULL , PRIMARY KEY (`id`, `Group_id`) , UNIQUE INDEX `userName_UNIQUE` (`userName...