You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
2.7 KiB

  1. /*
  2. * @Description: 建库建表语句
  3. * @Author: hai-27
  4. * @Date: 2020-02-07 16:51:58
  5. * @LastEditors: hai-27
  6. * @LastEditTime: 2020-03-27 15:36:01
  7. */
  8. create database storeDB;
  9. use storeDB;
  10. create table users(
  11. user_id int primary key auto_increment,
  12. userName char (40) not null unique,
  13. password char (40) not null,
  14. userPhoneNumber char(11) null
  15. );
  16. -- ALTER TABLE users MODIFY COLUMN userName char (40) not null unique;
  17. -- ALTER TABLE users MODIFY COLUMN password char (40) not null;
  18. -- insert into users
  19. -- values(null, 'admin', '123456', '100861001010000');
  20. create table carousel(
  21. carousel_id int primary key auto_increment,
  22. imgPath char (50) not null,
  23. describes char (50) not null
  24. );
  25. -- insert into carousel
  26. -- values(null, 'public/imgs/cms_1.jpg', '123456');
  27. -- insert into carousel
  28. -- values(null, 'public/imgs/cms_2.jpg', '123456');
  29. -- insert into carousel
  30. -- values(null, 'public/imgs/cms_3.jpg', '123456');
  31. -- insert into carousel
  32. -- values(null, 'public/imgs/cms_4.jpg', '123456');
  33. create table category(
  34. category_id int primary key auto_increment,
  35. category_name char(20) not null
  36. );
  37. create table product(
  38. product_id int primary key auto_increment,
  39. product_name char (100) not null,
  40. category_id int not null,
  41. product_title char (30) not null,
  42. product_intro text not null,
  43. product_picture char (200),
  44. product_price double not null,
  45. product_selling_price double not null,
  46. product_num int not null,
  47. product_sales int not null,
  48. constraint FK_product_category foreign key (category_id) references category (category_id)
  49. );
  50. create table product_picture(
  51. id int primary key auto_increment,
  52. product_id int not null,
  53. product_picture char (200),
  54. intro text null,
  55. constraint FK_product_id foreign key (product_id) references product (product_id)
  56. );
  57. create table shoppingCart(
  58. id int primary key auto_increment,
  59. user_id int not null,
  60. product_id int not null,
  61. num int not null,
  62. constraint FK_user_id foreign key (user_id) references users (user_id),
  63. constraint FK_shoppingCart_id foreign key (product_id) references product (product_id)
  64. );
  65. create table orders(
  66. id int primary key auto_increment,
  67. order_id bigint not null,
  68. user_id int not null,
  69. product_id int not null,
  70. product_num int not null,
  71. product_price double not null,
  72. order_time bigint not null,
  73. constraint FK_order_user_id foreign key (user_id) references users (user_id),
  74. constraint FK_order_id foreign key (product_id) references product (product_id)
  75. );
  76. create table collect(
  77. id int primary key auto_increment,
  78. user_id int not null,
  79. product_id int not null,
  80. collect_time bigint not null,
  81. constraint FK_collect_user_id foreign key (user_id) references users (user_id),
  82. constraint FK_collect_id foreign key (product_id) references product (product_id)
  83. );