Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. create table cities
  2. (
  3. id int(11) primary key auto_increment,
  4. name varchar(30) not null,
  5. country_name varchar(80) not null
  6. );
  7.  
  8. create table users
  9. (
  10. id int(11) primary key auto_increment,
  11. username varchar(50) unique not null,
  12. password varchar(255) not null,
  13. first_name varchar(50) not null,
  14. last_name varchar(50),
  15. age int(11) check(age>=18) ,
  16. money decimal(15,2) not null,
  17. city_id int(11) not null,
  18. register_date date not null,
  19. constraint FK_city_user foreign key(city_id)
  20. references cities(id)
  21. );
  22.  
  23. create table orders
  24. (
  25. id int(11) primary key auto_increment,
  26. user_id int(11) not null,
  27. constraint FK_city_user1 foreign key (user_id)
  28. references users(id),
  29. order_date date not null,
  30. is_completed bool default 0
  31. );
  32.  
  33. create table plants
  34. (
  35. id int(11) primary key auto_increment,
  36. name varchar(50) not null,
  37. price decimal(15,2) not null,
  38. color varchar(50),
  39. quantity int(11) default 0
  40. );
  41.  
  42. create table info_plants
  43. (
  44. id int(11) primary key auto_increment,
  45. plant_id int(11) not null,
  46. constraint FK_city_user3 foreign key(plant_id)
  47. references plants(id),
  48. family varchar(50) not null,
  49. genus varchar(40) not null,
  50. purpose varchar(60)
  51. );
  52.  
  53. create table plants_orders
  54. (
  55. plant_id int(11) not null,
  56. order_id int(11) not null,
  57. constraint FK_city_user2 foreign key(order_id)
  58. references orders(id)
  59. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement