Advertisement
lessientelrunya

DB Schema

Apr 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. PRAGMA foreign_keys = ON;
  2.  
  3. DROP TABLE if exists user;
  4. CREATE TABLE user (
  5.   id INTEGER PRIMARY KEY autoincrement,
  6.   username TEXT NOT NULL,
  7.   password TEXT NOT NULL,
  8.   first_name TEXT,
  9.   last_name TEXT,
  10.   birth_date DATE,
  11.   CHECK (
  12.       length("birth_date") = 10
  13.   )
  14. );
  15.  
  16. DROP TABLE if exists post;
  17. CREATE TABLE post (
  18.   id INTEGER PRIMARY KEY autoincrement,
  19.   user_id INTEGER,
  20.   created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  21.   content TEXT NOT NULL,
  22.   FOREIGN KEY(user_id) REFERENCES user(id),
  23.   CHECK(
  24.       typeof("content") = "text" AND
  25.       length("content") <= 140
  26.   )
  27. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement