Advertisement
Guest User

Untitled

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