diff --git "a/\346\236\227\345\277\227\344\270\207/01\345\210\235\350\257\206\346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" "b/\346\236\227\345\277\227\344\270\207/240901\345\210\235\350\257\206\346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" similarity index 100% rename from "\346\236\227\345\277\227\344\270\207/01\345\210\235\350\257\206\346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" rename to "\346\236\227\345\277\227\344\270\207/240901\345\210\235\350\257\206\346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" diff --git "a/\346\236\227\345\277\227\344\270\207/02picgo\347\232\204\344\275\277\347\224\250.md" "b/\346\236\227\345\277\227\344\270\207/240902picgo\347\232\204\344\275\277\347\224\250.md" similarity index 100% rename from "\346\236\227\345\277\227\344\270\207/02picgo\347\232\204\344\275\277\347\224\250.md" rename to "\346\236\227\345\277\227\344\270\207/240902picgo\347\232\204\344\275\277\347\224\250.md" diff --git "a/\346\236\227\345\277\227\344\270\207/03rbac\345\210\235\350\257\206.md" "b/\346\236\227\345\277\227\344\270\207/240903rbac\345\210\235\350\257\206.md" similarity index 100% rename from "\346\236\227\345\277\227\344\270\207/03rbac\345\210\235\350\257\206.md" rename to "\346\236\227\345\277\227\344\270\207/240903rbac\345\210\235\350\257\206.md" diff --git "a/\346\236\227\345\277\227\344\270\207/04\345\256\214\345\226\204\345\255\246\346\240\241\346\210\220\347\273\251\347\263\273\347\273\237.md" "b/\346\236\227\345\277\227\344\270\207/240904\345\256\214\345\226\204\345\255\246\346\240\241\346\210\220\347\273\251\347\263\273\347\273\237.md" similarity index 100% rename from "\346\236\227\345\277\227\344\270\207/04\345\256\214\345\226\204\345\255\246\346\240\241\346\210\220\347\273\251\347\263\273\347\273\237.md" rename to "\346\236\227\345\277\227\344\270\207/240904\345\256\214\345\226\204\345\255\246\346\240\241\346\210\220\347\273\251\347\263\273\347\273\237.md" diff --git "a/\346\236\227\345\277\227\344\270\207/240912\345\225\206\345\223\201\350\241\250.md" "b/\346\236\227\345\277\227\344\270\207/240912\345\225\206\345\223\201\350\241\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..6a6f8bd4fe23c37d07331513504ed825d0e4f1c6 --- /dev/null +++ "b/\346\236\227\345\277\227\344\270\207/240912\345\225\206\345\223\201\350\241\250.md" @@ -0,0 +1,141 @@ +商品表 + +1,概念模型 + +![image-20240912125924383](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20240912125924383.png) + +2,逻辑模型 + +![image-20240912125937819](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20240912125937819.png) + +3,物理模型 + +![image-20240912125950073](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20240912125950073.png) + +数据库代码 + +``` +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/12 12:55:00 */ +/*==============================================================*/ + + +drop table if exists Relationship_3; + +drop table if exists SKU; + +drop table if exists attribute; + +drop table if exists attribute_data; + +drop table if exists shop; + +/*==============================================================*/ +/* Table: Relationship_3 */ +/*==============================================================*/ +create table Relationship_3 +( + skuid char(10) not null, + aid int not null, + primary key (skuid, aid) +); + +/*==============================================================*/ +/* Table: SKU */ +/*==============================================================*/ +create table SKU +( + skuid char(10) not null, + sid int, + price char(10), + kucun char(10), + primary key (skuid) +); + +/*==============================================================*/ +/* Table: attribute */ +/*==============================================================*/ +create table attribute +( + id int not null, + size char(10), + primary key (id) +); + +/*==============================================================*/ +/* Table: attribute_data */ +/*==============================================================*/ +create table attribute_data +( + aid int not null, + id int, + attribute1 varchar(25), + primary key (aid) +); + +/*==============================================================*/ +/* Table: shop */ +/*==============================================================*/ +create table shop +( + sid int not null, + sname varchar(255), + brand varchar(255), + primary key (sid) +); + +alter table Relationship_3 add constraint FK_Relationship_3 foreign key (skuid) + references SKU (skuid) on delete restrict on update restrict; + +alter table Relationship_3 add constraint FK_Relationship_4 foreign key (aid) + references attribute_data (aid) on delete restrict on update restrict; + +alter table SKU add constraint FK_Relationship_1 foreign key (sid) + references shop (sid) on delete restrict on update restrict; + +alter table attribute_data add constraint FK_Relationship_2 foreign key (id) + references attribute (id) on delete restrict on update restrict; +``` + +添加数据 + +``` +INSERT INTO `goods` VALUES (1, 'SpringWind', '宋凯'); + +INSERT INTO `shuxing` VALUES (1, '套餐'); + +INSERT INTO `zhi` VALUES (1, 1, '基础'); +INSERT INTO `zhi` VALUES (2, 1, '升级'); +INSERT INTO `zhi` VALUES (3, 1, '豪华'); + +INSERT INTO `relationship_3` VALUES (1, 1); +INSERT INTO `relationship_3` VALUES (2, 1); +INSERT INTO `relationship_3` VALUES (1, 2); +INSERT INTO `relationship_3` VALUES (2, 2); +INSERT INTO `relationship_3` VALUES (1, 3); +INSERT INTO `relationship_3` VALUES (2, 3); + + +INSERT INTO `sku` VALUES (1, 1, 199, 50); +INSERT INTO `sku` VALUES (2, 1, 299, 100); +``` + +查询 + +``` +select gname 商品,brand 品牌,price 价格,value, weight 数量 from goods +join SKU s on goods.gid = s.gid + +join relationship_3 re on s.sku_id=re.sku_id +join zhi z on z.zid=re.zid + +WHERE price =299 and value = '基础 +``` + + + + + + +