Advertisement
STANAANDREY

psql scr1

Sep 6th, 2021
1,425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE IF NOT EXISTS users (
  2.     username TEXT PRIMARY KEY NOT NULL,
  3.     password TEXT NOT NULL
  4. );
  5.  
  6. CREATE TABLE IF NOT EXISTS elections (
  7.     candidate TEXT NOT NULL,
  8.     election_date DATE NOT NULL DEFAULT CURRENT_DATE,
  9.     FOREIGN KEY (candidate) REFERENCES users(username)
  10. );
  11.  
  12. CREATE TABLE IF NOT EXISTS user_votes (
  13.       voted_user TEXT NOT NULL UNIQUE REFERENCES elections(candidate),
  14.       user_who_voted TEXT NOT NULL REFERENCES users(username),
  15.       date_voted DATE NOT NULL DEFAULT CURRENT_DATE
  16.  );
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement