From 541d96bc33d4f210c2368a823ac5c2c24f5fa52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E7=A5=96=E4=BF=A1?= <483307635@qq.com> Date: Fri, 22 Sep 2023 12:40:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=96=9B=E7=A5=96=E4=BF=A1=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230921 \344\275\234\344\270\232.md" | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 "05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" diff --git "a/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" "b/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" new file mode 100644 index 0000000..9454778 --- /dev/null +++ "b/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" @@ -0,0 +1,112 @@ +笔记 + +``` +spu: 一种规格 +sku: 一种单位,唯一表示符 +``` + +代码 + +```mysql +s p u:标准化产品单元,是一组可重复用,易检索的标准化信息的集合; + +s k u:库存量最小单位(最小库存单位):即库存进出的计量单位,在服装,鞋类产品中使用最普遍 + +CREATE DATABASE x CHARSET utf8; +use x; +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-21 11:22:58 */ +/*==============================================================*/ + + +drop table if exists commodity; + +drop table if exists middle; + +drop table if exists property; + +drop table if exists specification; + +drop table if exists value; + +/*==============================================================*/ +/* Table: commodity */ +/*==============================================================*/ +create table commodity +( + co_id int not null auto_increment, + co_name varchar(30) not null, + introductory varchar(100) not null, + primary key (co_id) +); +INSERT into commodity VALUES (1,'华为手机Mate 60 Pro','遥遥领先'), +(2,'Redmi K60 至尊版 天玑9200+','小米配天玑越用越懵逼'); + +/*==============================================================*/ +/* Table: middle */ +/*==============================================================*/ +create table middle +( + m_id int not null auto_increment, + sp_id int, + p_id int, + v_id int, + primary key (m_id) +); +INSERT into middle VALUES(1,1,1,1),(2,1,2,5),(3,2,1,2),(4,2,2,8),(5,3,1,3),(6,3,2,6),(7,4,1,4),(8,4,2,7); + +/*==============================================================*/ +/* Table: property */ +/*==============================================================*/ +create table property +( + p_id int not null auto_increment, + p_name varchar(10) not null, + primary key (p_id) +); + +INSERT into property VALUES(1,'颜色'),(2,'存储版本'); +/*==============================================================*/ +/* Table: specification */ +/*==============================================================*/ +create table specification +( + sp_id int not null auto_increment, + co_id int, + sp_title varchar(50) not null, + price decimal(9,2) not null, + inventory varchar(10) not null, + primary key (sp_id) +); + +INSERT into specification VALUES (1,1,'华为(HUAWEI)旗舰手机 Mate 60 Pro 12GB+512GB ',6999,500),(2,1,'华为(HUAWEI)旗舰手机 Mate 60 Pro 12GB+1TB',7999,300),(3,2,' Redmi K60 至尊版 天玑9200+ 16GB+512GB',2999,5000),(4,2,' Redmi K60 至尊版 天玑9200+ 16GB+1TB',3299,5000); + +/*==============================================================*/ +/* Table: value */ +/*==============================================================*/ +create table value +( + v_id int not null auto_increment, + v_name varchar(20) not null, + primary key (v_id) +); + +INSERT into value VALUES(1,'雅川青'),(2,'鸭蛋黑'),(3,'晴雪'),(4,'耀眼的黑'),(5,'12GB+512GB'),(6,'16GB+512GB'),(7,'16GB+1TB'),(8,'12GB+1TB'); + + +alter table middle add constraint FK_Relationship_2 foreign key (sp_id) + references specification (sp_id) on delete restrict on update restrict; + +alter table middle add constraint FK_Relationship_3 foreign key (p_id) + references property (p_id) on delete restrict on update restrict; + +alter table middle add constraint FK_Relationship_4 foreign key (v_id) + references value (v_id) on delete restrict on update restrict; + +alter table specification add constraint FK_belong_pp foreign key (co_id) + references commodity (co_id) on delete restrict on update restrict; + +SELECT * from commodity c INNER JOIN specification s ON c.co_id=s.co_id INNER JOIN middle m ON s.sp_id=m.sp_id INNER JOIN property p ON m.p_id=p.p_id INNER JOIN value v on m.v_id=v.v_id where v.v_name='雅川青' OR c.co_name='华为手机Mate 60 Pro'; +``` + -- Gitee From 16c7dc1ee442beb9b1a92ef0bf86441df1c7e21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E7=A5=96=E4=BF=A1?= <483307635@qq.com> Date: Fri, 22 Sep 2023 12:42:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=96=9B=E7=A5=96=E4=BF=A1=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230921 \344\275\234\344\270\232.md" | 4 ---- 1 file changed, 4 deletions(-) diff --git "a/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" "b/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" index 9454778..c1ede06 100644 --- "a/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" +++ "b/05 \350\226\233\347\245\226\344\277\241/20230921 \344\275\234\344\270\232.md" @@ -8,10 +8,6 @@ sku: 一种单位,唯一表示符 代码 ```mysql -s p u:标准化产品单元,是一组可重复用,易检索的标准化信息的集合; - -s k u:库存量最小单位(最小库存单位):即库存进出的计量单位,在服装,鞋类产品中使用最普遍 - CREATE DATABASE x CHARSET utf8; use x; /*==============================================================*/ -- Gitee