Created
December 19, 2019 08:18
-
-
Save KielRodriguez/4a431dc13dfc94147a60cf6e250a94e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE account( | |
user_id serial PRIMARY KEY, | |
username VARCHAR (50) UNIQUE NOT NULL, | |
password VARCHAR (50) NOT NULL, | |
email VARCHAR (355) UNIQUE NOT NULL, | |
created_on TIMESTAMP NOT NULL, | |
last_login TIMESTAMP | |
); | |
CREATE TABLE role( | |
role_id serial PRIMARY KEY, | |
role_name VARCHAR (255) UNIQUE NOT NULL | |
); | |
CREATE TABLE account_role | |
( | |
user_id integer NOT NULL, | |
role_id integer NOT NULL, | |
grant_date timestamp without time zone, | |
PRIMARY KEY (user_id, role_id), | |
CONSTRAINT account_role_role_id_fkey FOREIGN KEY (role_id) | |
REFERENCES role (role_id) MATCH SIMPLE | |
ON UPDATE NO ACTION ON DELETE NO ACTION, | |
CONSTRAINT account_role_user_id_fkey FOREIGN KEY (user_id) | |
REFERENCES account (user_id) MATCH SIMPLE | |
ON UPDATE NO ACTION ON DELETE NO ACTION | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment