deleting user id field and adding collaborator foreing key from access

This commit is contained in:
Claudio Barril 2014-01-29 22:15:26 -03:00
parent 93a8647c6a
commit ccd5eb8e15
4 changed files with 20 additions and 9 deletions

View File

@ -4,8 +4,7 @@ CREATE TABLE COLLABORATOR (
creation_date DATE);
CREATE TABLE USER (
id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
colaborator_id INTEGER NOT NULL IDENTITY,
authentication_type CHAR(1) NOT NULL,
authenticator_uri VARCHAR(255) NULL,
firstname VARCHAR(255) NOT NULL,
@ -68,7 +67,10 @@ CREATE TABLE TAG
CREATE TABLE ACCESS_AUDITORY (
id INTEGER NOT NULL IDENTITY,
user_id INTEGER NOT NULL,
login_date DATE
login_date DATE,
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
COMMIT;

View File

@ -13,8 +13,7 @@ CREATE TABLE COLLABORATOR (
CHARACTER SET utf8;
CREATE TABLE USER (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
colaborator_id INTEGER NOT NULL,
colaborator_id INTEGER NOT NULL PRIMARY KEY,
authentication_type CHAR(1)
CHARACTER SET utf8 NOT NULL,
authenticator_uri VARCHAR(255)
@ -103,7 +102,10 @@ CREATE TABLE TAG (
CREATE TABLE ACCESS_AUDITORY (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
login_date DATE,
user_id INTEGER NOT NULL
user_id INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;

View File

@ -0,0 +1,7 @@
ALTER TABLE `USER` DROP COLUMN `id`;
ALTER TABLE `ACCESS_AUDITORY`
ADD CONSTRAINT
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION;

View File

@ -5,10 +5,9 @@ CREATE TABLE COLLABORATOR (
);
CREATE TABLE "user" (
id SERIAL NOT NULL PRIMARY KEY,
authentication_type TEXT NOT NULL,
authenticator_uri VARCHAR(255),
colaborator_id INTEGER NOT NULL,
colaborator_id INTEGER NOT NULL PRIMARY KEY,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
@ -73,7 +72,8 @@ CREATE TABLE TAG (
CREATE TABLE ACCESS_AUDITORY (
id SERIAL NOT NULL PRIMARY KEY,
login_date DATE,
user_id INTEGER NOT NULL
user_id INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES "user" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
);