schema.sql 853 B

1234567891011121314151617181920212223242526
  1. CREATE TABLE authors (
  2. author_id integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
  3. name text NOT NULL
  4. ) ENGINE=InnoDB;
  5. CREATE INDEX authors_name_idx ON authors(name(255));
  6. CREATE TABLE books (
  7. book_id integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
  8. author_id integer NOT NULL,
  9. isbn varchar(255) NOT NULL DEFAULT '' UNIQUE,
  10. book_type ENUM('FICTION', 'NONFICTION') NOT NULL DEFAULT 'FICTION',
  11. title text NOT NULL,
  12. yr integer NOT NULL DEFAULT 2000,
  13. available datetime NOT NULL DEFAULT NOW(),
  14. tags text NOT NULL
  15. -- CONSTRAINT FOREIGN KEY (author_id) REFERENCES authors(author_id)
  16. ) ENGINE=InnoDB;
  17. CREATE INDEX books_title_idx ON books(title(255), yr);
  18. /*
  19. CREATE FUNCTION say_hello(s text) RETURNS text
  20. DETERMINISTIC
  21. RETURN CONCAT('hello ', s);
  22. */