forked from khl1956/lab2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.sql
More file actions
166 lines (134 loc) · 6.49 KB
/
Copy pathcreate.sql
File metadata and controls
166 lines (134 loc) · 6.49 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*==============================================================*/
/* DBMS name: PostgreSQL 9.x */
/* Created on: 23.10.2019 21:44:16 */
/*==============================================================*/
/*
drop index "One presentation Has Many topics_FK";
drop index topic_PK;
drop table Topic;
drop index "User Have Many presentations_FK";
drop index presentation_PK;
drop table presentation;
drop index "Presentation Have Participants2_FK";
drop index "Presentation Have Participants_FK";
drop index "Presentation Have Participants_PK";
drop table Presentation_have_Participants;
drop index user_PK;
drop table user;
drop index Participant_PK;
drop table Participant;
*/
/*==============================================================*/
/* Table: topic */
/*==============================================================*/
create table topic (
topic_name VARCHAR(20) not null,
presentation_name VARCHAR(20) null,
constraint PK_topic primary key (topic_name)
);
/*==============================================================*/
/* Index: topic_PK */
/*==============================================================*/
create unique index topic_PK on topic (
topic_name
);
/*==============================================================*/
/* Index: "One presentation Has Many topics_FK" */
/*==============================================================*/
create index "One presentation Has Many topics_FK" on topic (
presentation_name
);
/*==============================================================*/
/* Table: presentation */
/*==============================================================*/
create table presentation (
presentation_name VARCHAR(20) not null,
user_email VARCHAR(20) null,
presentation_date DATE null,
constraint PK_presentation primary key (presentation_name)
);
/*==============================================================*/
/* Index: presentation_PK */
/*==============================================================*/
create unique index presentation_PK on presentation (
presentation_name
);
/*==============================================================*/
/* Index: "user Have Many presentations_FK" */
/*==============================================================*/
create index "user Have Many presentations_FK" on presentation (
user_email
);
/*==============================================================*/
/* Table: presentation_have_Participants */
/*==============================================================*/
create table presentation_have_Participants (
presentation_name VARCHAR(20) not null,
participant_list VARCHAR(30) not null,
constraint PK_presentation_HAVE_ParticipantS primary key (presentation_name, participant_list)
);
/*==============================================================*/
/* Index: "presentation Have Participants_PK" */
/*==============================================================*/
create unique index "presentation Have Participants_PK" on presentation_have_Participants (
presentation_name,
participant_list
);
/*==============================================================*/
/* Index: "presentation Have Participants_FK" */
/*==============================================================*/
create index "presentation Have Participants_FK" on presentation_have_Participants (
presentation_name
);
/*==============================================================*/
/* Index: "presentation Have Participants2_FK" */
/*==============================================================*/
create index "presentation Have Participants2_FK" on presentation_have_Participants (
participant_list
);
/*==============================================================*/
/* Table: user */
/*==============================================================*/
create table user (
user_email VARCHAR(20) not null,
user_name VARCHAR(20) null,
user_phone VARCHAR(20) null,
user_birthday DATE null,
constraint PK_user primary key (user_email)
);
/*==============================================================*/
/* Index: user_PK */
/*==============================================================*/
create unique index user_PK on user (
user_email
);
/*==============================================================*/
/* Table: Participant */
/*==============================================================*/
create table Participant (
participant_list VARCHAR(20) not null,
participant_name VARCHAR(50) null,
constraint PK_Participant primary key (participant_list)
);
/*==============================================================*/
/* Index: Participant_PK */
/*==============================================================*/
create unique index Participant_PK on Participant (
participant_list
);
alter table topic
add constraint "FK_topic_ONE presentation_presentation" foreign key (presentation_name)
references presentation (presentation_name)
on delete restrict on update restrict;
alter table presentation
add constraint "FK_presentation_ONE OF TH_user" foreign key (user_email)
references user (user_email)
on delete restrict on update restrict;
alter table presentation_have_Participants
add constraint "FK_presentation_HA_ONE presentation_presentation" foreign key (presentation_name)
references presentation (presentation_name)
on delete restrict on update restrict;
alter table presentation_have_Participants
add constraint "FK_presentation_HA_ONE presentation_Participant" foreign key (participant_list)
references Participant (participant_list)
on delete restrict on update restrict;