schema.sql 690 B

1234567891011121314151617181920
  1. CREATE TABLE authors (
  2. author_id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  3. name text NOT NULL
  4. );
  5. CREATE INDEX authors_name_idx ON authors(name);
  6. CREATE TABLE books (
  7. book_id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  8. author_id integer NOT NULL,
  9. isbn varchar(255) NOT NULL DEFAULT '' UNIQUE,
  10. book_type text NOT NULL DEFAULT 'FICTION',
  11. title text NOT NULL,
  12. yr integer NOT NULL DEFAULT 2000,
  13. available datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  14. tag text NOT NULL,
  15. CHECK (book_type = 'FICTION' OR book_type = 'NONFICTION')
  16. );
  17. CREATE INDEX books_title_idx ON books(title, yr);