Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.94 KB | None | 0 0
  1. use book_api_db;
  2.  
  3. create table books(
  4.     id varchar(255) unique not null,
  5.     image_link text,
  6.     page_count int ,
  7.     published_date varchar(200),
  8.     publisher varchar(200),
  9.     title text,
  10.     subtitle longtext,
  11.     primary key(id)
  12. );
  13.  
  14. create table categories(
  15.     id int auto_increment unique not null ,
  16.     name varchar(255) unique ,
  17.     parent_category int default 0,
  18.     primary key (id)
  19. );
  20.  
  21. create table authors(
  22.     id int auto_increment unique not null ,
  23.     name varchar(255) unique ,
  24.     primary key (id)
  25. );
  26.  
  27. create table book_categories(
  28.     book_id varchar(255) not null ,
  29.     category_id int not null,
  30.     foreign key (book_id) references books(id),
  31.     foreign key (category_id) references categories(id)
  32. );
  33.  
  34. create table book_authors(
  35.     book_id varchar(255) not null ,
  36.     author_id int not null ,
  37.     foreign key (book_id) references books(id),
  38.     foreign key (author_id) references authors(id)
  39. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement