Advertisement
Guest User

Untitled

a guest
Jan 11th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table account(
  2.     ID_account serial primary key,
  3.     username varchar(50) unique not null,
  4.     password VARCHAR (50) NOT NULL,
  5.     email VARCHAR (355) UNIQUE NOT NULL,
  6.     dateOfBirth date not null
  7.     );
  8.  
  9. create table role(
  10.     ID_role serial primary key,
  11.     roleName varchar(50) unique not null
  12.     );
  13.    
  14. create table accountRole(
  15.   ID_account integer NOT NULL,
  16.   ID_role integer NOT NULL,
  17.   PRIMARY KEY (ID_account, ID_role),
  18.   FOREIGN KEY (ID_role) REFERENCES role (ID_role),
  19.   FOREIGN KEY (ID_account) REFERENCES account (ID_account)
  20.     );
  21.    
  22. create table category(
  23.     ID_category serial primary key,
  24.     CategoryName varchar(100) not null
  25.     );
  26.    
  27. create table collection(
  28.     ID_collection serial primary key,
  29.     CollectionName varchar(100) not null,
  30.     foreign key (ID_account) references account (ID_account),
  31.     foreign key (ID_category) references category (ID_category)
  32.     );
  33.    
  34. create table deck(
  35.     ID_deck serial primary key,
  36.     DeckName varchar(100) not null,
  37.     foreign key (ID_collection) references collection (ID_collection)
  38.     );
  39.    
  40. create table results(
  41.     ID_result serial primary key,
  42.     result_value numeric not null,
  43.     comment varchar(300),
  44.     dateOfResult date not null,
  45.     foreign key (ID_deck) references deck (ID_deck)
  46.     );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement