forked from Cathe313/mysql-workshop-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise_1.txt
52 lines (46 loc) · 1.16 KB
/
exercise_1.txt
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
CREATE TABLE Account(
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(250),
password VARCHAR(40),
createdOn DATETIME,
modifiedOn DATETIME
);
CREATE TABLE AddressBook(
id INT AUTO_INCREMENT PRIMARY KEY,
accountId INT,
name VARCHAR(255),
createdOn DATETIME,
modifiedOn DATETIME
);
CREATE TABLE Entry(
id INT AUTO_INCREMENT PRIMARY KEY,
AddressBookId INT,
firstName VARCHAR(255),
lastName VARCHAR(255),
birthday DATETIME,
type ENUM('phone', 'address', 'electronic-mail')
);
CREATE TABLE Phone(
id INT AUTO_INCREMENT PRIMARY KEY,
entryId INT,
type ENUM('home', 'work', 'other'),
subtype ENUM('landline', 'cellular', 'fax'),
content VARCHAR(250)
);
CREATE TABLE Address(
id INT AUTO_INCREMENT PRIMARY KEY,
entryId INT,
type ENUM('home', 'work', 'other'),
addressLine1 VARCHAR(255),
addressLine2 VARCHAR(255),
city VARCHAR(255),
province VARCHAR(128),
country VARCHAR(128),
postalCode VARCHAR(10)
);
CREATE TABLE ElectronicMail(
id INT AUTO_INCREMENT PRIMARY KEY,
entryId INT,
type ENUM('home', 'work', 'other'),
content VARCHAR(255)
);