diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-02 18:00:32 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-02 18:00:32 +0100 |
commit | 018bdbf096cc7de6795413568e1ce1b56490aa6a (patch) | |
tree | 20dd8eaa44d70991b0ea7893757d8defb99e27da | |
parent | cccb84f247be3658dc7ec1009d21cfdf53d21c1e (diff) |
Database schema: Add missing primary key constraints.
-rw-r--r-- | schema.sql | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -25,18 +25,21 @@ CREATE TABLE users( CREATE TABLE passwords( "user" INTEGER NOT NULL, password VARCHAR NOT NULL, + PRIMARY KEY ("user", password), FOREIGN KEY ("user") REFERENCES users ); CREATE TABLE openids( "user" INTEGER NOT NULL, openid VARCHAR NOT NULL, + PRIMARY KEY ("user", openid), FOREIGN KEY ("user") REFERENCES users ); CREATE TABLE login_certificates( "user" INTEGER NOT NULL, - certificate BYTEA NOT NULL, + certificate BYTEA NOT NULL, + PRIMARY KEY ("user", certificate), FOREIGN KEY ("user") REFERENCES users ); @@ -90,12 +93,14 @@ CREATE TABLE article_revision_characteristics( revision INTEGER NOT NULL, characteristic VARCHAR NOT NULL, value VARCHAR, - FOREIGN KEY (revision) REFERENCES article_revisions + FOREIGN KEY (revision) REFERENCES article_revisions, + UNIQUE (revision, characteristic, value) ); CREATE TABLE article_revision_parenthood( parent_id INTEGER NOT NULL, child_id INTEGER NOT NULL, + PRIMARY KEY (parent_id, child_id), FOREIGN KEY (parent_id) REFERENCES article_revisions, FOREIGN KEY (child_id) REFERENCES article_revisions ); |