-
Notifications
You must be signed in to change notification settings - Fork 0
/
Skrypt do tworzenia tabel.sql
57 lines (52 loc) · 1.3 KB
/
Skrypt do tworzenia tabel.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use ZaawJava;
create table ZaawJava.countries
(
id int auto_increment primary key,
country_name varchar(45)
);
create table ZaawJava.languages
(
id int auto_increment primary key,
language_name varchar(45)
);
create table ZaawJava.users
(
id int auto_increment primary key,
first_name varchar(20),
last_name varchar(20),
phone int,
gender enum('male','female'),
email varchar(50) NOT NULL UNIQUE,
user_password varchar(50) NOT NULL,
address varchar(50),
country_id int ,
birth_date date,
photo varchar(255),
foreign key (country_id) references ZaawJava.countries(id)
);
create table ZaawJava.users_languages
(
user_id int,
language_id int,
foreign key (user_id) references ZaawJava.users(id),
foreign key (language_id) references ZaawJava.languages(id)
);
create table ZaawJava.conversations
(
conversation_id int auto_increment primary key,
user1 int,
user2 int,
foreign key (user1) references ZaawJava.users(id),
foreign key (user2) references ZaawJava.users(id),
CONSTRAINT UQ_UserId_ContactID UNIQUE(user1, user2)
);
create table ZaawJava.private_messages
(
message_id int auto_increment primary key,
conversation_id int,
sender int,
content text,
send_date datetime,
foreign key (conversation_id) references ZaawJava.conversations(conversation_id)
);
CREATE INDEX Datetime_Index ON ZaawJava.private_messages (send_date);