From 66a671d447422aa4edf581d384c3a5363a6e788b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0?= <11785149+denglingyan@user.noreply.gitee.com> Date: Tue, 12 Sep 2023 02:52:55 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E9=99=88=E6=9D=B0=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈杰 <11785149+denglingyan@user.noreply.gitee.com> --- .../20230910 \350\261\206\347\223\243.md" | 243 ++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 "07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" diff --git "a/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" "b/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" new file mode 100644 index 0000000..c0247e4 --- /dev/null +++ "b/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" @@ -0,0 +1,243 @@ +# 笔记 + +1. 概念模型CDM,ER图,人类角度 +2. 逻辑模型LDM,计算机角度 +3. 物理模型PDM,从具体数据库角度 +4. 生成DDL,数据定义语言 +5. 命名的所有名称,Code不要包涵 - 和 , ,最后标点符号只用_ 。 + + + + + +# 代码 + +```mysql +/* + Navicat Premium Data Transfer + + Source Server : lijunyang + Source Server Type : MySQL + Source Server Version : 50742 + Source Host : localhost:3306 + Source Schema : bbookkss + + Target Server Type : MySQL + Target Server Version : 50742 + File Encoding : 65001 + + Date: 10/09/2023 16:56:08 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for book +-- ---------------------------- +DROP TABLE IF EXISTS `book`; +CREATE TABLE `book` ( + `b_id` int(11) NOT NULL AUTO_INCREMENT, + `ty_id` int(11) NOT NULL, + `bo_id` int(11) NOT NULL, + `re_id` int(11) NOT NULL, + `b_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `b_money` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`b_id`) USING BTREE, + INDEX `FK_Relationship_7`(`ty_id`) USING BTREE, + INDEX `FK_Relationship_8`(`bo_id`) USING BTREE, + INDEX `FK_Relationship_9`(`re_id`) USING BTREE, + CONSTRAINT `FK_Relationship_7` FOREIGN KEY (`ty_id`) REFERENCES `typee` (`ty_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_8` FOREIGN KEY (`bo_id`) REFERENCES `borrow` (`bo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_9` FOREIGN KEY (`re_id`) REFERENCES `guihuan` (`re_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of book +-- ---------------------------- +INSERT INTO `book` VALUES (1, 1, 1, 1, '少林足球', '50元'); +INSERT INTO `book` VALUES (2, 1, 2, 2, '功夫', '58元'); +INSERT INTO `book` VALUES (3, 2, 3, 3, '无敌', '11元'); + +-- ---------------------------- +-- Table structure for borrow +-- ---------------------------- +DROP TABLE IF EXISTS `borrow`; +CREATE TABLE `borrow` ( + `bo_id` int(11) NOT NULL AUTO_INCREMENT, + `us_id` int(11) NOT NULL, + `bo_time` time NULL DEFAULT NULL, + PRIMARY KEY (`bo_id`) USING BTREE, + INDEX `FK_Relationship_2`(`us_id`) USING BTREE, + CONSTRAINT `FK_Relationship_2` FOREIGN KEY (`us_id`) REFERENCES `user` (`us_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of borrow +-- ---------------------------- +INSERT INTO `borrow` VALUES (1, 1, '22:00:00'); +INSERT INTO `borrow` VALUES (2, 2, '16:26:54'); +INSERT INTO `borrow` VALUES (3, 3, '16:27:11'); +INSERT INTO `borrow` VALUES (4, 4, '16:27:35'); + +-- ---------------------------- +-- Table structure for floor +-- ---------------------------- +DROP TABLE IF EXISTS `floor`; +CREATE TABLE `floor` ( + `fl_id` int(11) NOT NULL AUTO_INCREMENT, + `fl_name` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`fl_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of floor +-- ---------------------------- +INSERT INTO `floor` VALUES (1, '1楼'); +INSERT INTO `floor` VALUES (2, '2楼'); +INSERT INTO `floor` VALUES (3, '3楼'); +INSERT INTO `floor` VALUES (4, '4楼'); +INSERT INTO `floor` VALUES (5, '5楼'); + +-- ---------------------------- +-- Table structure for guihuan +-- ---------------------------- +DROP TABLE IF EXISTS `guihuan`; +CREATE TABLE `guihuan` ( + `re_id` int(11) NOT NULL AUTO_INCREMENT, + `us_id` int(11) NOT NULL, + `re_time` time NULL DEFAULT NULL, + PRIMARY KEY (`re_id`) USING BTREE, + INDEX `FK_Relationship_3`(`us_id`) USING BTREE, + CONSTRAINT `FK_Relationship_3` FOREIGN KEY (`us_id`) REFERENCES `user` (`us_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of guihuan +-- ---------------------------- +INSERT INTO `guihuan` VALUES (1, 1, '16:27:58'); +INSERT INTO `guihuan` VALUES (2, 2, '13:28:04'); +INSERT INTO `guihuan` VALUES (3, 3, '16:28:13'); +INSERT INTO `guihuan` VALUES (4, 4, '09:28:18'); + +-- ---------------------------- +-- Table structure for library +-- ---------------------------- +DROP TABLE IF EXISTS `library`; +CREATE TABLE `library` ( + `li_id` int(11) NOT NULL AUTO_INCREMENT, + `li_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`li_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of library +-- ---------------------------- +INSERT INTO `library` VALUES (1, '宇宙图书馆'); + +-- ---------------------------- +-- Table structure for relationship_4 +-- ---------------------------- +DROP TABLE IF EXISTS `relationship_4`; +CREATE TABLE `relationship_4` ( + `fl_id` int(11) NOT NULL, + `b_id` int(11) NOT NULL, + PRIMARY KEY (`fl_id`, `b_id`) USING BTREE, + INDEX `FK_Relationship_6`(`b_id`) USING BTREE, + CONSTRAINT `FK_Relationship_4` FOREIGN KEY (`fl_id`) REFERENCES `floor` (`fl_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_6` FOREIGN KEY (`b_id`) REFERENCES `book` (`b_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of relationship_4 +-- ---------------------------- +INSERT INTO `relationship_4` VALUES (1, 1); +INSERT INTO `relationship_4` VALUES (2, 2); +INSERT INTO `relationship_4` VALUES (2, 3); + +-- ---------------------------- +-- Table structure for relationship_5 +-- ---------------------------- +DROP TABLE IF EXISTS `relationship_5`; +CREATE TABLE `relationship_5` ( + `b_id` int(11) NOT NULL, + `st_id` int(11) NOT NULL, + PRIMARY KEY (`b_id`, `st_id`) USING BTREE, + INDEX `FK_Relationship_10`(`st_id`) USING BTREE, + CONSTRAINT `FK_Relationship_10` FOREIGN KEY (`st_id`) REFERENCES `staff` (`st_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_5` FOREIGN KEY (`b_id`) REFERENCES `book` (`b_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of relationship_5 +-- ---------------------------- +INSERT INTO `relationship_5` VALUES (1, 1); +INSERT INTO `relationship_5` VALUES (2, 1); +INSERT INTO `relationship_5` VALUES (3, 3); + +-- ---------------------------- +-- Table structure for staff +-- ---------------------------- +DROP TABLE IF EXISTS `staff`; +CREATE TABLE `staff` ( + `st_id` int(11) NOT NULL AUTO_INCREMENT, + `li_id` int(11) NOT NULL, + `st_name` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `st_sex` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `st_age` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`st_id`) USING BTREE, + INDEX `FK_Relationship_1`(`li_id`) USING BTREE, + CONSTRAINT `FK_Relationship_1` FOREIGN KEY (`li_id`) REFERENCES `library` (`li_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of staff +-- ---------------------------- +INSERT INTO `staff` VALUES (1, 1, '张三', '男', '11'); +INSERT INTO `staff` VALUES (2, 1, '李四', '男', '23'); +INSERT INTO `staff` VALUES (3, 1, '王五', '男', '12'); +INSERT INTO `staff` VALUES (4, 1, '赵六', '男', '11'); + +-- ---------------------------- +-- Table structure for typee +-- ---------------------------- +DROP TABLE IF EXISTS `typee`; +CREATE TABLE `typee` ( + `ty_id` int(11) NOT NULL AUTO_INCREMENT, + `ty_name` varchar(9) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`ty_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of typee +-- ---------------------------- +INSERT INTO `typee` VALUES (1, '搞笑'); +INSERT INTO `typee` VALUES (2, '恐怖'); +INSERT INTO `typee` VALUES (3, '综艺'); +INSERT INTO `typee` VALUES (4, '日常'); +INSERT INTO `typee` VALUES (5, '可爱'); + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `us_id` int(11) NOT NULL AUTO_INCREMENT, + `us_name` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `us_age` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `us_sex` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`us_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES (1, '迪迦', '11', '男'); +INSERT INTO `user` VALUES (2, '赛文', '34', '男'); +INSERT INTO `user` VALUES (3, '奥特之父', '33', '男'); +INSERT INTO `user` VALUES (4, '奥特曼', '22', '男'); + +SET FOREIGN_KEY_CHECKS = 1; + +``` + -- Gitee From 29c54aeeff8b8f4b9ffefbdbca9c0e475ea66580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0?= <11785149+denglingyan@user.noreply.gitee.com> Date: Tue, 12 Sep 2023 03:42:36 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2007?= =?UTF-8?q?=20=E9=99=88=E6=9D=B0/20230910=20=E8=B1=86=E7=93=A3.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230910 \350\261\206\347\223\243.md" | 243 ------------------ 1 file changed, 243 deletions(-) delete mode 100644 "07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" diff --git "a/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" "b/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" deleted file mode 100644 index c0247e4..0000000 --- "a/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" +++ /dev/null @@ -1,243 +0,0 @@ -# 笔记 - -1. 概念模型CDM,ER图,人类角度 -2. 逻辑模型LDM,计算机角度 -3. 物理模型PDM,从具体数据库角度 -4. 生成DDL,数据定义语言 -5. 命名的所有名称,Code不要包涵 - 和 , ,最后标点符号只用_ 。 - - - - - -# 代码 - -```mysql -/* - Navicat Premium Data Transfer - - Source Server : lijunyang - Source Server Type : MySQL - Source Server Version : 50742 - Source Host : localhost:3306 - Source Schema : bbookkss - - Target Server Type : MySQL - Target Server Version : 50742 - File Encoding : 65001 - - Date: 10/09/2023 16:56:08 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for book --- ---------------------------- -DROP TABLE IF EXISTS `book`; -CREATE TABLE `book` ( - `b_id` int(11) NOT NULL AUTO_INCREMENT, - `ty_id` int(11) NOT NULL, - `bo_id` int(11) NOT NULL, - `re_id` int(11) NOT NULL, - `b_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `b_money` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`b_id`) USING BTREE, - INDEX `FK_Relationship_7`(`ty_id`) USING BTREE, - INDEX `FK_Relationship_8`(`bo_id`) USING BTREE, - INDEX `FK_Relationship_9`(`re_id`) USING BTREE, - CONSTRAINT `FK_Relationship_7` FOREIGN KEY (`ty_id`) REFERENCES `typee` (`ty_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, - CONSTRAINT `FK_Relationship_8` FOREIGN KEY (`bo_id`) REFERENCES `borrow` (`bo_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, - CONSTRAINT `FK_Relationship_9` FOREIGN KEY (`re_id`) REFERENCES `guihuan` (`re_id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of book --- ---------------------------- -INSERT INTO `book` VALUES (1, 1, 1, 1, '少林足球', '50元'); -INSERT INTO `book` VALUES (2, 1, 2, 2, '功夫', '58元'); -INSERT INTO `book` VALUES (3, 2, 3, 3, '无敌', '11元'); - --- ---------------------------- --- Table structure for borrow --- ---------------------------- -DROP TABLE IF EXISTS `borrow`; -CREATE TABLE `borrow` ( - `bo_id` int(11) NOT NULL AUTO_INCREMENT, - `us_id` int(11) NOT NULL, - `bo_time` time NULL DEFAULT NULL, - PRIMARY KEY (`bo_id`) USING BTREE, - INDEX `FK_Relationship_2`(`us_id`) USING BTREE, - CONSTRAINT `FK_Relationship_2` FOREIGN KEY (`us_id`) REFERENCES `user` (`us_id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of borrow --- ---------------------------- -INSERT INTO `borrow` VALUES (1, 1, '22:00:00'); -INSERT INTO `borrow` VALUES (2, 2, '16:26:54'); -INSERT INTO `borrow` VALUES (3, 3, '16:27:11'); -INSERT INTO `borrow` VALUES (4, 4, '16:27:35'); - --- ---------------------------- --- Table structure for floor --- ---------------------------- -DROP TABLE IF EXISTS `floor`; -CREATE TABLE `floor` ( - `fl_id` int(11) NOT NULL AUTO_INCREMENT, - `fl_name` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - PRIMARY KEY (`fl_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of floor --- ---------------------------- -INSERT INTO `floor` VALUES (1, '1楼'); -INSERT INTO `floor` VALUES (2, '2楼'); -INSERT INTO `floor` VALUES (3, '3楼'); -INSERT INTO `floor` VALUES (4, '4楼'); -INSERT INTO `floor` VALUES (5, '5楼'); - --- ---------------------------- --- Table structure for guihuan --- ---------------------------- -DROP TABLE IF EXISTS `guihuan`; -CREATE TABLE `guihuan` ( - `re_id` int(11) NOT NULL AUTO_INCREMENT, - `us_id` int(11) NOT NULL, - `re_time` time NULL DEFAULT NULL, - PRIMARY KEY (`re_id`) USING BTREE, - INDEX `FK_Relationship_3`(`us_id`) USING BTREE, - CONSTRAINT `FK_Relationship_3` FOREIGN KEY (`us_id`) REFERENCES `user` (`us_id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of guihuan --- ---------------------------- -INSERT INTO `guihuan` VALUES (1, 1, '16:27:58'); -INSERT INTO `guihuan` VALUES (2, 2, '13:28:04'); -INSERT INTO `guihuan` VALUES (3, 3, '16:28:13'); -INSERT INTO `guihuan` VALUES (4, 4, '09:28:18'); - --- ---------------------------- --- Table structure for library --- ---------------------------- -DROP TABLE IF EXISTS `library`; -CREATE TABLE `library` ( - `li_id` int(11) NOT NULL AUTO_INCREMENT, - `li_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - PRIMARY KEY (`li_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of library --- ---------------------------- -INSERT INTO `library` VALUES (1, '宇宙图书馆'); - --- ---------------------------- --- Table structure for relationship_4 --- ---------------------------- -DROP TABLE IF EXISTS `relationship_4`; -CREATE TABLE `relationship_4` ( - `fl_id` int(11) NOT NULL, - `b_id` int(11) NOT NULL, - PRIMARY KEY (`fl_id`, `b_id`) USING BTREE, - INDEX `FK_Relationship_6`(`b_id`) USING BTREE, - CONSTRAINT `FK_Relationship_4` FOREIGN KEY (`fl_id`) REFERENCES `floor` (`fl_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, - CONSTRAINT `FK_Relationship_6` FOREIGN KEY (`b_id`) REFERENCES `book` (`b_id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of relationship_4 --- ---------------------------- -INSERT INTO `relationship_4` VALUES (1, 1); -INSERT INTO `relationship_4` VALUES (2, 2); -INSERT INTO `relationship_4` VALUES (2, 3); - --- ---------------------------- --- Table structure for relationship_5 --- ---------------------------- -DROP TABLE IF EXISTS `relationship_5`; -CREATE TABLE `relationship_5` ( - `b_id` int(11) NOT NULL, - `st_id` int(11) NOT NULL, - PRIMARY KEY (`b_id`, `st_id`) USING BTREE, - INDEX `FK_Relationship_10`(`st_id`) USING BTREE, - CONSTRAINT `FK_Relationship_10` FOREIGN KEY (`st_id`) REFERENCES `staff` (`st_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, - CONSTRAINT `FK_Relationship_5` FOREIGN KEY (`b_id`) REFERENCES `book` (`b_id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of relationship_5 --- ---------------------------- -INSERT INTO `relationship_5` VALUES (1, 1); -INSERT INTO `relationship_5` VALUES (2, 1); -INSERT INTO `relationship_5` VALUES (3, 3); - --- ---------------------------- --- Table structure for staff --- ---------------------------- -DROP TABLE IF EXISTS `staff`; -CREATE TABLE `staff` ( - `st_id` int(11) NOT NULL AUTO_INCREMENT, - `li_id` int(11) NOT NULL, - `st_name` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `st_sex` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `st_age` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`st_id`) USING BTREE, - INDEX `FK_Relationship_1`(`li_id`) USING BTREE, - CONSTRAINT `FK_Relationship_1` FOREIGN KEY (`li_id`) REFERENCES `library` (`li_id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of staff --- ---------------------------- -INSERT INTO `staff` VALUES (1, 1, '张三', '男', '11'); -INSERT INTO `staff` VALUES (2, 1, '李四', '男', '23'); -INSERT INTO `staff` VALUES (3, 1, '王五', '男', '12'); -INSERT INTO `staff` VALUES (4, 1, '赵六', '男', '11'); - --- ---------------------------- --- Table structure for typee --- ---------------------------- -DROP TABLE IF EXISTS `typee`; -CREATE TABLE `typee` ( - `ty_id` int(11) NOT NULL AUTO_INCREMENT, - `ty_name` varchar(9) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - PRIMARY KEY (`ty_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of typee --- ---------------------------- -INSERT INTO `typee` VALUES (1, '搞笑'); -INSERT INTO `typee` VALUES (2, '恐怖'); -INSERT INTO `typee` VALUES (3, '综艺'); -INSERT INTO `typee` VALUES (4, '日常'); -INSERT INTO `typee` VALUES (5, '可爱'); - --- ---------------------------- --- Table structure for user --- ---------------------------- -DROP TABLE IF EXISTS `user`; -CREATE TABLE `user` ( - `us_id` int(11) NOT NULL AUTO_INCREMENT, - `us_name` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `us_age` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `us_sex` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`us_id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of user --- ---------------------------- -INSERT INTO `user` VALUES (1, '迪迦', '11', '男'); -INSERT INTO `user` VALUES (2, '赛文', '34', '男'); -INSERT INTO `user` VALUES (3, '奥特之父', '33', '男'); -INSERT INTO `user` VALUES (4, '奥特曼', '22', '男'); - -SET FOREIGN_KEY_CHECKS = 1; - -``` - -- Gitee From 0acdfce1f31c76bfe1e2ae93581cb85f2eb6bad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0?= <11785149+denglingyan@user.noreply.gitee.com> Date: Tue, 12 Sep 2023 03:42:46 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E9=99=88=E6=9D=B0=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈杰 <11785149+denglingyan@user.noreply.gitee.com> --- .../20230910 \350\261\206\347\223\243.md" | 276 ++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 "07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" diff --git "a/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" "b/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" new file mode 100644 index 0000000..f982c36 --- /dev/null +++ "b/07 \351\231\210\346\235\260/20230910 \350\261\206\347\223\243.md" @@ -0,0 +1,276 @@ +# 笔记 + +1. 概念模型CDM,ER图,人类角度 +2. 逻辑模型LDM,计算机角度 +3. 物理模型PDM,从具体数据库角度 +4. 生成DDL,数据定义语言 +5. 命名的所有名称,Code不要包涵 - 和 , ,最后标点符号只用_ 。 + + + + + +# 代码 + +```mysql +/* + Navicat Premium Data Transfer + + Source Server : lijunyang + Source Server Type : MySQL + Source Server Version : 50742 + Source Host : localhost:3306 + Source Schema : movies + + Target Server Type : MySQL + Target Server Version : 50742 + File Encoding : 65001 + + Date: 11/09/2023 21:00:32 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for actor +-- ---------------------------- +DROP TABLE IF EXISTS `actor`; +CREATE TABLE `actor` ( + `actor_id` int(11) NOT NULL AUTO_INCREMENT, + `actor_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `actor_sex` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `actor_age` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`actor_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of actor +-- ---------------------------- +INSERT INTO `actor` VALUES (1, '迪迦', '男', '11'); +INSERT INTO `actor` VALUES (2, '赛文', '男', '12'); +INSERT INTO `actor` VALUES (3, '奥特之母', '男', '13'); +INSERT INTO `actor` VALUES (4, '奥特之父', '男', '14'); +INSERT INTO `actor` VALUES (5, '盖亚', '男', '15'); + +-- ---------------------------- +-- Table structure for awards +-- ---------------------------- +DROP TABLE IF EXISTS `awards`; +CREATE TABLE `awards` ( + `awards_id` int(11) NOT NULL AUTO_INCREMENT, + `awards_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`awards_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of awards +-- ---------------------------- +INSERT INTO `awards` VALUES (1, '最佳观影奖'); +INSERT INTO `awards` VALUES (2, '最好看奖'); +INSERT INTO `awards` VALUES (3, '最nb奖'); + +-- ---------------------------- +-- Table structure for language +-- ---------------------------- +DROP TABLE IF EXISTS `language`; +CREATE TABLE `language` ( + `language_id` int(11) NOT NULL AUTO_INCREMENT, + `language_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`language_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of language +-- ---------------------------- +INSERT INTO `language` VALUES (1, '汉语'); +INSERT INTO `language` VALUES (2, '英语'); +INSERT INTO `language` VALUES (3, '法语'); + +-- ---------------------------- +-- Table structure for movie +-- ---------------------------- +DROP TABLE IF EXISTS `movie`; +CREATE TABLE `movie` ( + `movie_id` int(11) NOT NULL AUTO_INCREMENT, + `type_id` int(11) NOT NULL, + `language_id` int(11) NOT NULL, + `synopsis_id` int(11) NOT NULL, + `movie_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `movie_day` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `movie_time` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `movie_alias` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`movie_id`) USING BTREE, + INDEX `FK_Relationship_2`(`type_id`) USING BTREE, + INDEX `FK_Relationship_4`(`language_id`) USING BTREE, + INDEX `FK_Relationship_7`(`synopsis_id`) USING BTREE, + CONSTRAINT `FK_Relationship_2` FOREIGN KEY (`type_id`) REFERENCES `type` (`type_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_4` FOREIGN KEY (`language_id`) REFERENCES `language` (`language_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_7` FOREIGN KEY (`synopsis_id`) REFERENCES `synopsis` (`synopsis_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of movie +-- ---------------------------- +INSERT INTO `movie` VALUES (1, 1, 1, 1, '出发,太阳系', '2022', '112分', '流浪地球'); +INSERT INTO `movie` VALUES (2, 2, 2, 2, '削肾客的救赎', '2021', '111分', '肖申克的救赎'); +INSERT INTO `movie` VALUES (3, 3, 3, 3, '我们的世界', '2019', '192分', '楚门的世界'); + +-- ---------------------------- +-- Table structure for movie_actor +-- ---------------------------- +DROP TABLE IF EXISTS `movie_actor`; +CREATE TABLE `movie_actor` ( + `actor_id` int(11) NOT NULL, + `movie_id` int(11) NOT NULL, + PRIMARY KEY (`actor_id`, `movie_id`) USING BTREE, + INDEX `FK_movie_actor2`(`movie_id`) USING BTREE, + CONSTRAINT `FK_movie_actor` FOREIGN KEY (`actor_id`) REFERENCES `actor` (`actor_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_movie_actor2` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of movie_actor +-- ---------------------------- +INSERT INTO `movie_actor` VALUES (1, 1); +INSERT INTO `movie_actor` VALUES (2, 1); +INSERT INTO `movie_actor` VALUES (3, 1); +INSERT INTO `movie_actor` VALUES (1, 2); +INSERT INTO `movie_actor` VALUES (2, 2); +INSERT INTO `movie_actor` VALUES (4, 3); +INSERT INTO `movie_actor` VALUES (5, 3); + +-- ---------------------------- +-- Table structure for people +-- ---------------------------- +DROP TABLE IF EXISTS `people`; +CREATE TABLE `people` ( + `evaluate_id` int(11) NOT NULL AUTO_INCREMENT, + `evaluate_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`evaluate_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of people +-- ---------------------------- +INSERT INTO `people` VALUES (1, '张三'); +INSERT INTO `people` VALUES (2, '李四'); +INSERT INTO `people` VALUES (3, '王五'); +INSERT INTO `people` VALUES (4, '赵六'); + +-- ---------------------------- +-- Table structure for relationship_3 +-- ---------------------------- +DROP TABLE IF EXISTS `relationship_3`; +CREATE TABLE `relationship_3` ( + `state_id` int(11) NOT NULL, + `movie_id` int(11) NOT NULL, + PRIMARY KEY (`state_id`, `movie_id`) USING BTREE, + INDEX `FK_Relationship_8`(`movie_id`) USING BTREE, + CONSTRAINT `FK_Relationship_3` FOREIGN KEY (`state_id`) REFERENCES `state` (`state_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_8` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of relationship_3 +-- ---------------------------- +INSERT INTO `relationship_3` VALUES (1, 1); +INSERT INTO `relationship_3` VALUES (2, 2); +INSERT INTO `relationship_3` VALUES (3, 3); + +-- ---------------------------- +-- Table structure for relationship_5 +-- ---------------------------- +DROP TABLE IF EXISTS `relationship_5`; +CREATE TABLE `relationship_5` ( + `awards_id` int(11) NOT NULL, + `movie_id` int(11) NOT NULL, + PRIMARY KEY (`awards_id`, `movie_id`) USING BTREE, + INDEX `FK_Relationship_9`(`movie_id`) USING BTREE, + CONSTRAINT `FK_Relationship_5` FOREIGN KEY (`awards_id`) REFERENCES `awards` (`awards_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_9` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of relationship_5 +-- ---------------------------- +INSERT INTO `relationship_5` VALUES (1, 1); +INSERT INTO `relationship_5` VALUES (2, 2); +INSERT INTO `relationship_5` VALUES (3, 3); + +-- ---------------------------- +-- Table structure for relationship_6 +-- ---------------------------- +DROP TABLE IF EXISTS `relationship_6`; +CREATE TABLE `relationship_6` ( + `evaluate_id` int(11) NOT NULL, + `movie_id` int(11) NOT NULL, + `content` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`evaluate_id`, `movie_id`) USING BTREE, + INDEX `FK_Relationship_10`(`movie_id`) USING BTREE, + CONSTRAINT `FK_Relationship_10` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_6` FOREIGN KEY (`evaluate_id`) REFERENCES `people` (`evaluate_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of relationship_6 +-- ---------------------------- +INSERT INTO `relationship_6` VALUES (1, 1, '非常好看的一部国产科幻电影'); +INSERT INTO `relationship_6` VALUES (2, 2, '非常好看的监狱逃离电影'); +INSERT INTO `relationship_6` VALUES (3, 3, '为楚门感到高兴'); + +-- ---------------------------- +-- Table structure for state +-- ---------------------------- +DROP TABLE IF EXISTS `state`; +CREATE TABLE `state` ( + `state_id` int(11) NOT NULL AUTO_INCREMENT, + `state_name` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`state_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of state +-- ---------------------------- +INSERT INTO `state` VALUES (1, '中国'); +INSERT INTO `state` VALUES (2, '美国'); +INSERT INTO `state` VALUES (3, '英国'); + +-- ---------------------------- +-- Table structure for synopsis +-- ---------------------------- +DROP TABLE IF EXISTS `synopsis`; +CREATE TABLE `synopsis` ( + `synopsis_id` int(11) NOT NULL AUTO_INCREMENT, + `synopsis_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`synopsis_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of synopsis +-- ---------------------------- +INSERT INTO `synopsis` VALUES (1, '一场伟大的逃离太阳系之路'); +INSERT INTO `synopsis` VALUES (2, '一位被冤枉的人的逃离监狱之路'); +INSERT INTO `synopsis` VALUES (3, '一场演出的闹剧'); + +-- ---------------------------- +-- Table structure for type +-- ---------------------------- +DROP TABLE IF EXISTS `type`; +CREATE TABLE `type` ( + `type_id` int(11) NOT NULL AUTO_INCREMENT, + `type_name` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`type_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of type +-- ---------------------------- +INSERT INTO `type` VALUES (1, '科幻'); +INSERT INTO `type` VALUES (2, '治愈'); +INSERT INTO `type` VALUES (3, '心理'); + +SET FOREIGN_KEY_CHECKS = 1; + +``` + -- Gitee