-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript_final.txt
123 lines (110 loc) · 2.29 KB
/
script_final.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
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
Drop table order_table
/
Drop table registry
/
Drop table song
/
Drop table album
/
Drop table author
/
Drop table pictures
/
Drop table store_table
/
Drop table user_table
/
Create table user_table
(
user_id Integer NOT NULL ,
username Varchar2(30) NOT NULL ,
surname Varchar2(30) NOT NULL ,
user_password Varchar2(30) NOT NULL ,
nickname Varchar2(30) NOT NULL ,
user_type Char(1) NOT NULL
)
/
Create table store_table
(
store_id Number NOT NULL ,
store_name Varchar2(30) NOT NULL ,
city Varchar2(30) NOT NULL ,
street Varchar2(30) NOT NULL
)
/
Create table pictures
(
picture_id Number NOT NULL ,
picture_data Blob NOT NULL
)
/
drop type author_obj
/
Create type author_obj as object
(
author_id Number ,
author_name Varchar2(30) ,
surname Varchar2(30) ,
nationality Varchar2(30)
);
/
Create table author of author_obj
(constraint author_tab_pk primary key(author_id));
Create table album
(
album_id Number NOT NULL ,
picture_id Number NOT NULL ,
title Varchar2(30) NOT NULL ,
genre Varchar2(30) NOT NULL ,
release_date Date NOT NULL
)
/
Create table song
(
song_id Number NOT NULL ,
album_id Number NOT NULL ,
author_id Number NOT NULL ,
song_length Number NOT NULL ,
title Varchar2(30) NOT NULL
)
/
Create table order_table
(
song_id Number NOT NULL ,
user_id Integer NOT NULL ,
order_id Number NOT NULL ,
order_date Date
)
/
Create table registry
(
song_id Number NOT NULL ,
store_id Number NOT NULL
)
/
Alter table song add primary key (song_id)
/
Alter table user_table add primary key (user_id)
/
Alter table store_table add primary key (store_id)
/
Alter table registry add primary key (song_id,store_id)
/
Alter table author add primary key (author_id)
/
Alter table album add primary key (album_id)
/
Alter table order_table add primary key (song_id,user_id)
/
Alter table registry add foreign key (song_id) references song (song_id)
/
Alter table order_table add foreign key (song_id) references song (song_id)
/
Alter table order_table add foreign key (user_id) references user_table (user_id)
/
Alter table registry add foreign key (store_id) references store_table (store_id)
/
Alter table song add foreign key (author_id) references author (author_id)
/
Alter table song add foreign key (album_id) references album (album_id)
/