· 6 years ago · Aug 04, 2019, 01:00 AM
1create table playlist
2(
3 id integer primary key not null,
4 ... other columns ...
5);
6
7create table playlistmovies
8(
9 id integer primary key not null,
10 playlist_id integer not null,
11 ... other columns
12);
13
14alter table playlistmovies
15 add constraint fk_plm_playlist
16 foreign key (playlist_id) references playlist(id)
17 on delete cascade;
18
19CREATE TABLE IF NOT EXISTS TestRecord
20(
21 -- Primary key column
22 id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
23
24 -- Example fields
25 sValue VARCHAR(100),
26 iValue INTEGER,
27);
28
29
30CREATE TABLE IF NOT EXISTS TestRecordJoin
31(
32 -- Foreign key column, specifying cascade delete behavior.
33 kRecord INTEGER NOT NULL FOREIGN KEY REFERENCES TestRecord ON DELETE CASCADE,
34
35 -- Example fields
36 sValue2 VARCHAR(64) NOT NULL,
37 iValue2 INTEGER NOT NULL
38);