diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-03-23 15:57:36 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-03-23 15:57:36 -0700 |
| commit | a6bbef0937649cd92a4b378a8454a96e6110bd99 (patch) | |
| tree | 582079ef3abdce03aeefa1b3b9ddd5d352bc9843 /database/many_to_many_example.postgres | |
| parent | 00c7f6129f87d77788aa92e08dd77b7b473f9a71 (diff) | |
Diffstat (limited to 'database/many_to_many_example.postgres')
| -rw-r--r-- | database/many_to_many_example.postgres | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/database/many_to_many_example.postgres b/database/many_to_many_example.postgres new file mode 100644 index 0000000..6a4ef56 --- /dev/null +++ b/database/many_to_many_example.postgres @@ -0,0 +1,16 @@ +CREATE TABLE cds( +id serial PRIMARY KEY -- implicit primary key constraint, +title text NOT NULL +); + +CREATE TABLE artists( +id serial PRIMARY KEY, +name text NOT NULL +); + +CREATE TABLE cds_and_artists( +cds_id integer REFERENCES cds (id) ON UPDATE CASCADE ON DELETE CASCADE, +artists_id integer REFERENCES artisys (id) ON UPDATE CASCADE, +CONSTRAINT cds_and_artists_pkey PRIMARY KEY (cds_id, artists_id) +); + |
