-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
530 lines (475 loc) · 20.1 KB
/
database.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
/*
Navicat Premium Data Transfer
Source Server : PostgreSQL-Local
Source Server Type : PostgreSQL
Source Server Version : 100001
Source Host : localhost:5432
Source Catalog : MusicDB
Source Schema : public
Target Server Type : PostgreSQL
Target Server Version : 100001
File Encoding : 65001
Date: 02/02/2018 16:26:44
*/
-- ----------------------------
-- Sequence structure for Albums_album_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."Albums_album_id_seq";
CREATE SEQUENCE "public"."Albums_album_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for Artists_artist_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."Artists_artist_id_seq";
CREATE SEQUENCE "public"."Artists_artist_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for Featurings_featuring_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."Featurings_featuring_id_seq";
CREATE SEQUENCE "public"."Featurings_featuring_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for Genres_genre_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."Genres_genre_id_seq";
CREATE SEQUENCE "public"."Genres_genre_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for Lyrics_lyric_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."Lyrics_lyric_id_seq";
CREATE SEQUENCE "public"."Lyrics_lyric_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for Songs_song_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."Songs_song_id_seq";
CREATE SEQUENCE "public"."Songs_song_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Table structure for Albums
-- ----------------------------
DROP TABLE IF EXISTS "public"."Albums";
CREATE TABLE "public"."Albums" (
"album_id" int4 NOT NULL DEFAULT nextval('"Albums_album_id_seq"'::regclass),
"album_name" varchar COLLATE "pg_catalog"."default",
"artist_id" int4,
"barcode" varchar COLLATE "pg_catalog"."default",
"country" varchar COLLATE "pg_catalog"."default",
"is_single" bool,
"release_year" int4
)
;
-- ----------------------------
-- Table structure for Artists
-- ----------------------------
DROP TABLE IF EXISTS "public"."Artists";
CREATE TABLE "public"."Artists" (
"artist_id" int4 NOT NULL DEFAULT nextval('"Artists_artist_id_seq"'::regclass),
"artist_name" varchar COLLATE "pg_catalog"."default",
"country" varchar COLLATE "pg_catalog"."default",
"is_group" bool,
"real_name" varchar COLLATE "pg_catalog"."default",
"started_year" int4
)
;
-- ----------------------------
-- Table structure for Featurings
-- ----------------------------
DROP TABLE IF EXISTS "public"."Featurings";
CREATE TABLE "public"."Featurings" (
"featuring_id" int4 NOT NULL DEFAULT nextval('"Featurings_featuring_id_seq"'::regclass),
"artist_id" int4,
"song_id" int4
)
;
-- ----------------------------
-- Table structure for Genres
-- ----------------------------
DROP TABLE IF EXISTS "public"."Genres";
CREATE TABLE "public"."Genres" (
"genre_id" int4 NOT NULL DEFAULT nextval('"Genres_genre_id_seq"'::regclass),
"genre_name" varchar COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for Lyrics
-- ----------------------------
DROP TABLE IF EXISTS "public"."Lyrics";
CREATE TABLE "public"."Lyrics" (
"lyric_id" int4 NOT NULL DEFAULT nextval('"Lyrics_lyric_id_seq"'::regclass),
"language" varchar COLLATE "pg_catalog"."default",
"lyrics" text COLLATE "pg_catalog"."default",
"song_id" int4
)
;
-- ----------------------------
-- Table structure for Songs
-- ----------------------------
DROP TABLE IF EXISTS "public"."Songs";
CREATE TABLE "public"."Songs" (
"song_id" int4 NOT NULL DEFAULT nextval('"Songs_song_id_seq"'::regclass),
"album_id" int4,
"artist_id" int4,
"genre_id" int4,
"is_featuring" bool,
"language" varchar COLLATE "pg_catalog"."default",
"song_name" varchar COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for log_table
-- ----------------------------
DROP TABLE IF EXISTS "public"."log_table";
CREATE TABLE "public"."log_table" (
"table_name" varchar COLLATE "pg_catalog"."default",
"operation" text COLLATE "pg_catalog"."default",
"data_new" text COLLATE "pg_catalog"."default",
"data_old" text COLLATE "pg_catalog"."default",
"process_date" date,
"id" int4 NOT NULL DEFAULT nextval('"Artists_artist_id_seq"'::regclass)
)
;
-- ----------------------------
-- Function structure for delete_log_function
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."delete_log_function"();
CREATE OR REPLACE FUNCTION "public"."delete_log_function"()
RETURNS "pg_catalog"."trigger" AS $BODY$
begin
insert into log_table(table_name,operation,data_new,data_old,process_date)
values(TG_TABLE_NAME::TEXT,TG_OP,'',ROW(OLD.*),CURRENT_TIMESTAMP);
return NEW;
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
-- ----------------------------
-- Function structure for insert_log_function
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."insert_log_function"();
CREATE OR REPLACE FUNCTION "public"."insert_log_function"()
RETURNS "pg_catalog"."trigger" AS $BODY$
begin
insert into log_table(table_name,operation,data_new,data_old,process_date)
values(TG_TABLE_NAME::TEXT,TG_OP,ROW(NEW.*),'',CURRENT_TIMESTAMP);
return NEW;
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
-- ----------------------------
-- Function structure for pg_buffercache_pages
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."pg_buffercache_pages"();
CREATE OR REPLACE FUNCTION "public"."pg_buffercache_pages"()
RETURNS SETOF "pg_catalog"."record" AS '$libdir/pg_buffercache', 'pg_buffercache_pages'
LANGUAGE c VOLATILE
COST 1
ROWS 1000;
-- ----------------------------
-- Function structure for pg_stat_statements
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."pg_stat_statements"(IN "showtext" bool, OUT "userid" oid, OUT "dbid" oid, OUT "queryid" int8, OUT "query" text, OUT "calls" int8, OUT "total_time" float8, OUT "min_time" float8, OUT "max_time" float8, OUT "mean_time" float8, OUT "stddev_time" float8, OUT "rows" int8, OUT "shared_blks_hit" int8, OUT "shared_blks_read" int8, OUT "shared_blks_dirtied" int8, OUT "shared_blks_written" int8, OUT "local_blks_hit" int8, OUT "local_blks_read" int8, OUT "local_blks_dirtied" int8, OUT "local_blks_written" int8, OUT "temp_blks_read" int8, OUT "temp_blks_written" int8, OUT "blk_read_time" float8, OUT "blk_write_time" float8);
CREATE OR REPLACE FUNCTION "public"."pg_stat_statements"(IN "showtext" bool, OUT "userid" oid, OUT "dbid" oid, OUT "queryid" int8, OUT "query" text, OUT "calls" int8, OUT "total_time" float8, OUT "min_time" float8, OUT "max_time" float8, OUT "mean_time" float8, OUT "stddev_time" float8, OUT "rows" int8, OUT "shared_blks_hit" int8, OUT "shared_blks_read" int8, OUT "shared_blks_dirtied" int8, OUT "shared_blks_written" int8, OUT "local_blks_hit" int8, OUT "local_blks_read" int8, OUT "local_blks_dirtied" int8, OUT "local_blks_written" int8, OUT "temp_blks_read" int8, OUT "temp_blks_written" int8, OUT "blk_read_time" float8, OUT "blk_write_time" float8)
RETURNS SETOF "pg_catalog"."record" AS '$libdir/pg_stat_statements', 'pg_stat_statements_1_3'
LANGUAGE c VOLATILE STRICT
COST 1
ROWS 1000;
-- ----------------------------
-- Function structure for pg_stat_statements_reset
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."pg_stat_statements_reset"();
CREATE OR REPLACE FUNCTION "public"."pg_stat_statements_reset"()
RETURNS "pg_catalog"."void" AS '$libdir/pg_stat_statements', 'pg_stat_statements_reset'
LANGUAGE c VOLATILE
COST 1;
-- ----------------------------
-- Function structure for update_log_function
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."update_log_function"();
CREATE OR REPLACE FUNCTION "public"."update_log_function"()
RETURNS "pg_catalog"."trigger" AS $BODY$
begin
insert into log_table(table_name,operation,data_new,data_old,process_date)
values(TG_TABLE_NAME::TEXT,TG_OP,ROW(NEW.*),ROW(OLD.*),CURRENT_TIMESTAMP);
return new;
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
-- ----------------------------
-- View structure for pg_stat_statements
-- ----------------------------
DROP VIEW IF EXISTS "public"."pg_stat_statements";
CREATE VIEW "public"."pg_stat_statements" AS SELECT pg_stat_statements.userid,
pg_stat_statements.dbid,
pg_stat_statements.queryid,
pg_stat_statements.query,
pg_stat_statements.calls,
pg_stat_statements.total_time,
pg_stat_statements.min_time,
pg_stat_statements.max_time,
pg_stat_statements.mean_time,
pg_stat_statements.stddev_time,
pg_stat_statements.rows,
pg_stat_statements.shared_blks_hit,
pg_stat_statements.shared_blks_read,
pg_stat_statements.shared_blks_dirtied,
pg_stat_statements.shared_blks_written,
pg_stat_statements.local_blks_hit,
pg_stat_statements.local_blks_read,
pg_stat_statements.local_blks_dirtied,
pg_stat_statements.local_blks_written,
pg_stat_statements.temp_blks_read,
pg_stat_statements.temp_blks_written,
pg_stat_statements.blk_read_time,
pg_stat_statements.blk_write_time
FROM pg_stat_statements(true) pg_stat_statements(userid, dbid, queryid, query, calls, total_time, min_time, max_time, mean_time, stddev_time, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time, blk_write_time);
-- ----------------------------
-- View structure for pg_buffercache
-- ----------------------------
DROP VIEW IF EXISTS "public"."pg_buffercache";
CREATE VIEW "public"."pg_buffercache" AS SELECT p.bufferid,
p.relfilenode,
p.reltablespace,
p.reldatabase,
p.relforknumber,
p.relblocknumber,
p.isdirty,
p.usagecount,
p.pinning_backends
FROM pg_buffercache_pages() p(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid, relforknumber smallint, relblocknumber bigint, isdirty boolean, usagecount smallint, pinning_backends integer);
-- ----------------------------
-- View structure for song_info
-- ----------------------------
DROP VIEW IF EXISTS "public"."song_info";
CREATE VIEW "public"."song_info" AS SELECT "Songs".song_id,
"Songs".song_name,
"Artists".artist_name,
"Albums".album_name,
"Lyrics".lyrics,
"Genres".genre_name,
"Songs".language
FROM (((("Songs"
JOIN "Artists" ON (("Songs".artist_id = "Artists".artist_id)))
JOIN "Albums" ON (("Songs".album_id = "Albums".album_id)))
JOIN "Genres" ON (("Songs".genre_id = "Genres".genre_id)))
LEFT JOIN "Lyrics" ON (("Songs".song_id = "Lyrics".song_id)));
-- ----------------------------
-- View structure for featuring_info
-- ----------------------------
DROP VIEW IF EXISTS "public"."featuring_info";
CREATE VIEW "public"."featuring_info" AS SELECT "Songs".song_id,
( SELECT "Artists_1".artist_name
FROM "Artists" "Artists_1"
WHERE ("Artists_1".artist_id = "Songs".artist_id)) AS sahibi,
string_agg((( SELECT "Artists_1".artist_name
FROM "Artists" "Artists_1"
WHERE ("Artists_1".artist_id = "Featurings".artist_id)))::text, ', '::text) AS "düetciler",
( SELECT "Albums".album_name
FROM "Albums"
WHERE ("Albums".album_id = "Songs".album_id)) AS album_adi,
"Songs".song_name
FROM (("Songs"
JOIN "Featurings" ON (("Songs".song_id = "Featurings".song_id)))
JOIN "Artists" ON (("Featurings".artist_id = "Artists".artist_id)))
GROUP BY "Songs".song_id;
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."Albums_album_id_seq"
OWNED BY "public"."Albums"."album_id";
SELECT setval('"public"."Albums_album_id_seq"', 460, true);
ALTER SEQUENCE "public"."Artists_artist_id_seq"
OWNED BY "public"."Artists"."artist_id";
SELECT setval('"public"."Artists_artist_id_seq"', 1983, true);
ALTER SEQUENCE "public"."Featurings_featuring_id_seq"
OWNED BY "public"."Featurings"."featuring_id";
SELECT setval('"public"."Featurings_featuring_id_seq"', 364, true);
ALTER SEQUENCE "public"."Genres_genre_id_seq"
OWNED BY "public"."Genres"."genre_id";
SELECT setval('"public"."Genres_genre_id_seq"', 1916, true);
ALTER SEQUENCE "public"."Lyrics_lyric_id_seq"
OWNED BY "public"."Lyrics"."lyric_id";
SELECT setval('"public"."Lyrics_lyric_id_seq"', 217, true);
ALTER SEQUENCE "public"."Songs_song_id_seq"
OWNED BY "public"."Songs"."song_id";
SELECT setval('"public"."Songs_song_id_seq"', 863, true);
-- ----------------------------
-- Indexes structure for table Albums
-- ----------------------------
CREATE INDEX "IX_Albums_artist_id" ON "public"."Albums" USING btree (
"artist_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
-- ----------------------------
-- Triggers structure for table Albums
-- ----------------------------
CREATE TRIGGER "album_delete_log" AFTER DELETE ON "public"."Albums"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_log_function"();
CREATE TRIGGER "album_insert_log" AFTER INSERT ON "public"."Albums"
FOR EACH ROW
EXECUTE PROCEDURE "public"."insert_log_function"();
CREATE TRIGGER "album_update_log" AFTER UPDATE ON "public"."Albums"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_log_function"();
-- ----------------------------
-- Primary Key structure for table Albums
-- ----------------------------
ALTER TABLE "public"."Albums" ADD CONSTRAINT "PK_Albums" PRIMARY KEY ("album_id");
-- ----------------------------
-- Triggers structure for table Artists
-- ----------------------------
CREATE TRIGGER "artist_delete_log" AFTER DELETE ON "public"."Artists"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_log_function"();
CREATE TRIGGER "artist_insert_log" AFTER INSERT ON "public"."Artists"
FOR EACH ROW
EXECUTE PROCEDURE "public"."insert_log_function"();
CREATE TRIGGER "artist_update_log" AFTER UPDATE ON "public"."Artists"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_log_function"();
-- ----------------------------
-- Primary Key structure for table Artists
-- ----------------------------
ALTER TABLE "public"."Artists" ADD CONSTRAINT "PK_Artists" PRIMARY KEY ("artist_id");
-- ----------------------------
-- Indexes structure for table Featurings
-- ----------------------------
CREATE INDEX "IX_Featurings_artist_id" ON "public"."Featurings" USING btree (
"artist_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "IX_Featurings_song_id" ON "public"."Featurings" USING btree (
"song_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
-- ----------------------------
-- Triggers structure for table Featurings
-- ----------------------------
CREATE TRIGGER "featuring_delete_log" AFTER DELETE ON "public"."Featurings"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_log_function"();
CREATE TRIGGER "featuring_insert_log" AFTER INSERT ON "public"."Featurings"
FOR EACH ROW
EXECUTE PROCEDURE "public"."insert_log_function"();
CREATE TRIGGER "featuring_update_log" AFTER UPDATE ON "public"."Featurings"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_log_function"();
-- ----------------------------
-- Primary Key structure for table Featurings
-- ----------------------------
ALTER TABLE "public"."Featurings" ADD CONSTRAINT "PK_Featurings" PRIMARY KEY ("featuring_id");
-- ----------------------------
-- Triggers structure for table Genres
-- ----------------------------
CREATE TRIGGER "genre_delete_log" AFTER DELETE ON "public"."Genres"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_log_function"();
CREATE TRIGGER "genre_insert_log" AFTER INSERT ON "public"."Genres"
FOR EACH ROW
EXECUTE PROCEDURE "public"."insert_log_function"();
CREATE TRIGGER "genre_update_log" AFTER UPDATE ON "public"."Genres"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_log_function"();
-- ----------------------------
-- Primary Key structure for table Genres
-- ----------------------------
ALTER TABLE "public"."Genres" ADD CONSTRAINT "PK_Genres" PRIMARY KEY ("genre_id");
-- ----------------------------
-- Indexes structure for table Lyrics
-- ----------------------------
CREATE UNIQUE INDEX "IX_Lyrics_song_id" ON "public"."Lyrics" USING btree (
"song_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
-- ----------------------------
-- Triggers structure for table Lyrics
-- ----------------------------
CREATE TRIGGER "lyric_delete_log" AFTER DELETE ON "public"."Lyrics"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_log_function"();
CREATE TRIGGER "lyric_insert_log" AFTER INSERT ON "public"."Lyrics"
FOR EACH ROW
EXECUTE PROCEDURE "public"."insert_log_function"();
CREATE TRIGGER "lyric_update_log" AFTER UPDATE ON "public"."Lyrics"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_log_function"();
-- ----------------------------
-- Primary Key structure for table Lyrics
-- ----------------------------
ALTER TABLE "public"."Lyrics" ADD CONSTRAINT "PK_Lyrics" PRIMARY KEY ("lyric_id");
-- ----------------------------
-- Indexes structure for table Songs
-- ----------------------------
CREATE INDEX "IX_Songs_album_id" ON "public"."Songs" USING btree (
"album_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "IX_Songs_artist_id" ON "public"."Songs" USING btree (
"artist_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "IX_Songs_genre_id" ON "public"."Songs" USING btree (
"genre_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
-- ----------------------------
-- Triggers structure for table Songs
-- ----------------------------
CREATE TRIGGER "song_delete_log" AFTER DELETE ON "public"."Songs"
FOR EACH ROW
EXECUTE PROCEDURE "public"."delete_log_function"();
CREATE TRIGGER "song_insert_log" AFTER INSERT ON "public"."Songs"
FOR EACH ROW
EXECUTE PROCEDURE "public"."insert_log_function"();
CREATE TRIGGER "song_update_log" AFTER UPDATE ON "public"."Songs"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_log_function"();
-- ----------------------------
-- Primary Key structure for table Songs
-- ----------------------------
ALTER TABLE "public"."Songs" ADD CONSTRAINT "PK_Songs" PRIMARY KEY ("song_id");
-- ----------------------------
-- Primary Key structure for table log_table
-- ----------------------------
ALTER TABLE "public"."log_table" ADD CONSTRAINT "log_table_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Foreign Keys structure for table Albums
-- ----------------------------
ALTER TABLE "public"."Albums" ADD CONSTRAINT "FK_Albums_Artists_artist_id" FOREIGN KEY ("artist_id") REFERENCES "Artists" ("artist_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- ----------------------------
-- Foreign Keys structure for table Featurings
-- ----------------------------
ALTER TABLE "public"."Featurings" ADD CONSTRAINT "FK_Featurings_Artists_artist_id" FOREIGN KEY ("artist_id") REFERENCES "Artists" ("artist_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."Featurings" ADD CONSTRAINT "FK_Featurings_Songs_song_id" FOREIGN KEY ("song_id") REFERENCES "Songs" ("song_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- ----------------------------
-- Foreign Keys structure for table Lyrics
-- ----------------------------
ALTER TABLE "public"."Lyrics" ADD CONSTRAINT "FK_Lyrics_Songs_song_id" FOREIGN KEY ("song_id") REFERENCES "Songs" ("song_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- ----------------------------
-- Foreign Keys structure for table Songs
-- ----------------------------
ALTER TABLE "public"."Songs" ADD CONSTRAINT "FK_Songs_Albums_album_id" FOREIGN KEY ("album_id") REFERENCES "Albums" ("album_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."Songs" ADD CONSTRAINT "FK_Songs_Artists_artist_id" FOREIGN KEY ("artist_id") REFERENCES "Artists" ("artist_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."Songs" ADD CONSTRAINT "FK_Songs_Genres_genre_id" FOREIGN KEY ("genre_id") REFERENCES "Genres" ("genre_id") ON DELETE CASCADE ON UPDATE CASCADE;