-
Notifications
You must be signed in to change notification settings - Fork 1
/
dbcreation.sql
29 lines (27 loc) · 1.05 KB
/
dbcreation.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CREATE DATABASE ContactManager;
CREATE TABLE `ContactManager`.`users`
(
`id` INT NOT NULL auto_increment,
`datecreated` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`datelastloggedin` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`firstname` VARCHAR(50) NOT NULL DEFAULT '',
`lastname` VARCHAR(50) NOT NULL DEFAULT '',
`login` VARCHAR(50) NOT NULL DEFAULT '',
`password` VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
)
engine = innodb;
CREATE TABLE `ContactManager`.`contacts`
(
`id` INT NOT NULL auto_increment,
`firstname` VARCHAR(50) NOT NULL DEFAULT '',
`lastname` VARCHAR(50) NOT NULL DEFAULT '',
`userid` INT NOT NULL DEFAULT '0',
`phone` VARCHAR(50) NOT NULL DEFAULT '',
`email` VARCHAR(50) NOT NULL DEFAULT '',
`description` VARCHAR(100) NOT NULL DEFAULT '',
`lastupdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (userid) REFERENCES users(id)
)
engine = innodb;