diff --git "a/33\351\227\253\347\273\247\345\221\250/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" "b/33\351\227\253\347\273\247\345\221\250/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" new file mode 100644 index 0000000000000000000000000000000000000000..b3938c67e34696037b1ef6107c03705973c447e7 --- /dev/null +++ "b/33\351\227\253\347\273\247\345\221\250/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" @@ -0,0 +1,260 @@ +if exists(select 1 from sys.sysforeignkey where role='FK_BORROW2_BORROW_LIBRARY') then + alter table Borrow2 + delete foreign key FK_BORROW2_BORROW_LIBRARY +end if; + +if exists(select 1 from sys.sysforeignkey where role='FK_BORROW2_BORROW2_BORROW') then + alter table Borrow2 + delete foreign key FK_BORROW2_BORROW2_BORROW +end if; + +if exists(select 1 from sys.sysforeignkey where role='FK_MANAGE_MANAGE_LIBRARY') then + alter table manage + delete foreign key FK_MANAGE_MANAGE_LIBRARY +end if; + +if exists(select 1 from sys.sysforeignkey where role='FK_MANAGE_MANAGE2_WORKING') then + alter table manage + delete foreign key FK_MANAGE_MANAGE2_WORKING +end if; + +if exists(select 1 from sys.sysforeignkey where role='FK_SERVE_SERVE_WORKING') then + alter table serve + delete foreign key FK_SERVE_SERVE_WORKING +end if; + +if exists(select 1 from sys.sysforeignkey where role='FK_SERVE_SERVE2_BORROW') then + alter table serve + delete foreign key FK_SERVE_SERVE2_BORROW +end if; + +drop index if exists Borrow.Borrow_PK; + +drop table if exists Borrow; + +drop index if exists Borrow2.Borrow2_FK; + +drop index if exists Borrow2.Borrow_FK; + +drop index if exists Borrow2.Borrow2_PK; + +drop table if exists Borrow2; + +drop index if exists library.library_PK; + +drop table if exists library; + +drop index if exists manage.manage2_FK; + +drop index if exists manage.manage_FK; + +drop index if exists manage.manage_PK; + +drop table if exists manage; + +drop index if exists serve.serve_FK; + +drop index if exists serve.serve2_FK; + +drop index if exists serve.serve_PK; + +drop table if exists serve; + +drop index if exists "working personnel"."working personnel_PK"; + +drop table if exists "working personnel"; + +/*==============================================================*/ +/* Table: Borrow */ +/*==============================================================*/ +create table Borrow +( + Bor_id integer not null, + Bor_name varchar(10) not null, + Bor_level integer not null, + Bor_blacklist varchar(10) not null, + constraint PK_BORROW primary key (Bor_id) +); + +/*==============================================================*/ +/* Index: Borrow_PK */ +/*==============================================================*/ +create unique index Borrow_PK on Borrow ( +Bor_id ASC +); + +/*==============================================================*/ +/* Table: Borrow2 */ +/*==============================================================*/ +create table Borrow2 +( + lib_id integer not null, + Bor_id integer not null, + situation char(4) not null, + constraint PK_BORROW2 primary key (lib_id, Bor_id) +); + +/*==============================================================*/ +/* Index: Borrow2_PK */ +/*==============================================================*/ +create unique index Borrow2_PK on Borrow2 ( +lib_id ASC, +Bor_id ASC +); + +/*==============================================================*/ +/* Index: Borrow_FK */ +/*==============================================================*/ +create index Borrow_FK on Borrow2 ( +lib_id ASC +); + +/*==============================================================*/ +/* Index: Borrow2_FK */ +/*==============================================================*/ +create index Borrow2_FK on Borrow2 ( +Bor_id ASC +); + +/*==============================================================*/ +/* Table: library */ +/*==============================================================*/ +create table library +( + lib_id integer not null, + lib_name varchar(20) not null, + lib_state varchar(3) not null, + lib_author varchar(10) not null, + lib_publish varchar(20) not null, + lib_classes integer not null, + constraint PK_LIBRARY primary key (lib_id) +); + +/*==============================================================*/ +/* Index: library_PK */ +/*==============================================================*/ +create unique index library_PK on library ( +lib_id ASC +); + +/*==============================================================*/ +/* Table: manage */ +/*==============================================================*/ +create table manage +( + lib_id integer not null, + wor_id integer not null, + lib_state varchar(2) not null, + constraint PK_MANAGE primary key (lib_id, wor_id) +); + +/*==============================================================*/ +/* Index: manage_PK */ +/*==============================================================*/ +create unique index manage_PK on manage ( +lib_id ASC, +wor_id ASC +); + +/*==============================================================*/ +/* Index: manage_FK */ +/*==============================================================*/ +create index manage_FK on manage ( +lib_id ASC +); + +/*==============================================================*/ +/* Index: manage2_FK */ +/*==============================================================*/ +create index manage2_FK on manage ( +wor_id ASC +); + +/*==============================================================*/ +/* Table: serve */ +/*==============================================================*/ +create table serve +( + wor_id integer not null, + Bor_id integer not null, + constraint PK_SERVE primary key (wor_id, Bor_id) +); + +/*==============================================================*/ +/* Index: serve_PK */ +/*==============================================================*/ +create unique index serve_PK on serve ( +wor_id ASC, +Bor_id ASC +); + +/*==============================================================*/ +/* Index: serve2_FK */ +/*==============================================================*/ +create index serve2_FK on serve ( +Bor_id ASC +); + +/*==============================================================*/ +/* Index: serve_FK */ +/*==============================================================*/ +create index serve_FK on serve ( +wor_id ASC +); + +/*==============================================================*/ +/* Table: "working personnel" */ +/*==============================================================*/ +create table "working personnel" +( + wor_id integer not null, + wor_name varchar(4) not null, + wor_position varchar(10) not null, + wor_range varchar(20) not null, + wor_state varchar(4) not null, + constraint "PK_WORKING PERSONNEL" primary key (wor_id) +); + +/*==============================================================*/ +/* Index: "working personnel_PK" */ +/*==============================================================*/ +create unique index "working personnel_PK" on "working personnel" ( +wor_id ASC +); + +alter table Borrow2 + add constraint FK_BORROW2_BORROW_LIBRARY foreign key (lib_id) + references library (lib_id) + on update restrict + on delete restrict; + +alter table Borrow2 + add constraint FK_BORROW2_BORROW2_BORROW foreign key (Bor_id) + references Borrow (Bor_id) + on update restrict + on delete restrict; + +alter table manage + add constraint FK_MANAGE_MANAGE_LIBRARY foreign key (lib_id) + references library (lib_id) + on update restrict + on delete restrict; + +alter table manage + add constraint FK_MANAGE_MANAGE2_WORKING foreign key (wor_id) + references "working personnel" (wor_id) + on update restrict + on delete restrict; + +alter table serve + add constraint FK_SERVE_SERVE_WORKING foreign key (wor_id) + references "working personnel" (wor_id) + on update restrict + on delete restrict; + +alter table serve + add constraint FK_SERVE_SERVE2_BORROW foreign key (Bor_id) + references Borrow (Bor_id) + on update restrict + on delete restrict; +``` \ No newline at end of file diff --git "a/33\351\227\253\347\273\247\345\221\250/\347\224\265\345\275\261\347\263\273\347\273\237.md" "b/33\351\227\253\347\273\247\345\221\250/\347\224\265\345\275\261\347\263\273\347\273\237.md" new file mode 100644 index 0000000000000000000000000000000000000000..aea3f8506218d13936527650c1cc71f8926a38b9 --- /dev/null +++ "b/33\351\227\253\347\273\247\345\221\250/\347\224\265\345\275\261\347\263\273\347\273\237.md" @@ -0,0 +1,179 @@ +![https://i.niupic.com/images/2023/09/12/bEaF.png](https://i.niupic.com/images/2023/09/12/bEaF.png) + +1、笔记 + + 1.找到PicGo的客户端,成功上传图片 + +2.在CDM模型中,实体与实体之间可以多条连线 + + + + + +```mysql +/* + Navicat Premium Data Transfer + + Source Server : qiqi + Source Server Type : MySQL + Source Server Version : 50741 + Source Host : localhost:3306 + Source Schema : tushu + + Target Server Type : MySQL + Target Server Version : 50741 + File Encoding : 65001 + + Date: 12/09/2023 13:20:37 +*/ +drop DATABASE tushu; +CREATE DATABASE tushu charset utf8; +use tushu; + + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for actors +-- ---------------------------- +DROP TABLE IF EXISTS `actors`; +CREATE TABLE `actors` ( + `fm_id` int(11) NOT NULL, + `m_id` varchar(14) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `zhiwu` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`fm_id`, `m_id`) USING BTREE, + INDEX `FK_actors2`(`m_id`) USING BTREE, + CONSTRAINT `FK_actors` FOREIGN KEY (`fm_id`) REFERENCES `filmmaker` (`fm_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_actors2` FOREIGN KEY (`m_id`) REFERENCES `movie` (`m_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of actors +-- ---------------------------- + +-- ---------------------------- +-- Table structure for comment +-- ---------------------------- +DROP TABLE IF EXISTS `comment`; +CREATE TABLE `comment` ( + `cm_id` int(11) NOT NULL AUTO_INCREMENT, + `u_idd` int(11) NULL DEFAULT NULL, + `m_id` varchar(14) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `c_disagree` int(11) NULL DEFAULT NULL, + `c_date` datetime NULL DEFAULT NULL, + `c_agree` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`cm_id`) USING BTREE, + INDEX `FK_Relationship_1`(`u_idd`) USING BTREE, + INDEX `FK_Relationship_4`(`m_id`) USING BTREE, + CONSTRAINT `FK_Relationship_1` FOREIGN KEY (`u_idd`) REFERENCES `user` (`u_idd`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_4` FOREIGN KEY (`m_id`) REFERENCES `movie` (`m_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of comment +-- ---------------------------- +INSERT INTO `comment` VALUES (1, 1, '1', 0, '2023-09-20 13:19:35', 1); +INSERT INTO `comment` VALUES (2, 3, '1', 0, '2023-09-15 13:20:06', 1); + +-- ---------------------------- +-- Table structure for country +-- ---------------------------- +DROP TABLE IF EXISTS `country`; +CREATE TABLE `country` ( + `country_id` int(10) NOT NULL AUTO_INCREMENT, + `country_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `language` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`country_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of country +-- ---------------------------- +INSERT INTO `country` VALUES (1, '美国', '英语'); +INSERT INTO `country` VALUES (2, '韩国', '韩语'); + +-- ---------------------------- +-- Table structure for filmmaker +-- ---------------------------- +DROP TABLE IF EXISTS `filmmaker`; +CREATE TABLE `filmmaker` ( + `fm_id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `sex` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `age` int(11) NULL DEFAULT NULL, + `master_work` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `contact` varchar(18) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`fm_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of filmmaker +-- ---------------------------- +INSERT INTO `filmmaker` VALUES (1, '席琳·宋', '女', 11, '导演,编剧', '1222'); +INSERT INTO `filmmaker` VALUES (2, ' 格蕾塔·李', '男', 22, '主演', '100'); +INSERT INTO `filmmaker` VALUES (3, '刘台午', '男', 33, '主演', '2222'); +INSERT INTO `filmmaker` VALUES (4, ' 约翰·马加罗', '女', 44, '主演', '4444'); +INSERT INTO `filmmaker` VALUES (5, ' 文胜雅', '男', 55, '主演', '5555'); +INSERT INTO `filmmaker` VALUES (6, '尹智慧', '女', 66, '主演', '6666'); + +-- ---------------------------- +-- Table structure for movie +-- ---------------------------- +DROP TABLE IF EXISTS `movie`; +CREATE TABLE `movie` ( + `m_id` varchar(14) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `type_id` int(11) NULL DEFAULT NULL, + `country_id` int(11) NULL DEFAULT NULL, + `m_name` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `m_award` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `m_length` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `m_intro` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`m_id`) USING BTREE, + INDEX `FK_Relationship_3`(`type_id`) USING BTREE, + INDEX `FK_Relationship_6`(`country_id`) USING BTREE, + CONSTRAINT `FK_Relationship_3` FOREIGN KEY (`type_id`) REFERENCES `movietype` (`type_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Relationship_6` FOREIGN KEY (`country_id`) REFERENCES `country` (`country_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of movie +-- ---------------------------- +INSERT INTO `movie` VALUES ('1', 1, 1, '过往人生', '第73届柏林国际电影节', '106', 'Nora(Greta Lee 饰)自小便因家庭因素搬离首尔移居加拿大。她与青梅竹马 Hae Sung(刘台午 饰)的关系最终停留在稚幼的凝视不语。而在二十年后,命运令两人于纽约重逢。可此时 Nora已拥有新的身份,甚至已和Arthur(John Magaro 饰)建立家庭。和Hae Sung 分开二十年后的重逢,也令她重新思索生活中的真正渴望。'); + +-- ---------------------------- +-- Table structure for movietype +-- ---------------------------- +DROP TABLE IF EXISTS `movietype`; +CREATE TABLE `movietype` ( + `type_id` int(10) NOT NULL AUTO_INCREMENT, + `type_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`type_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of movietype +-- ---------------------------- +INSERT INTO `movietype` VALUES (1, '爱情'); + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `u_idd` int(11) NOT NULL AUTO_INCREMENT, + `u_id` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `u_IP` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `u_name` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`u_idd`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES (1, '2', '美国', 'Seb’s '); +INSERT INTO `user` VALUES (3, '4', '法国', 'DeadVolcano '); + +SET FOREIGN_KEY_CHECKS = 1; + +``` \ No newline at end of file diff --git "a/33\351\227\253\347\273\247\345\221\250/\347\254\254\344\270\211\350\212\202\350\257\276\347\254\224\350\256\260.md" "b/33\351\227\253\347\273\247\345\221\250/\347\254\254\344\270\211\350\212\202\350\257\276\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..3e44f60029667b52175525ec75d72cd09b151183 --- /dev/null +++ "b/33\351\227\253\347\273\247\345\221\250/\347\254\254\344\270\211\350\212\202\350\257\276\347\254\224\350\256\260.md" @@ -0,0 +1,9 @@ +数据库的范式: + +1.第一范式:要求字段的内容,不可再分割,为的是保证数据的原子性。 + +2.第二范式:要求在满足第一范式的基础上,要求非主键字段要完全依赖主键,(非主键要依赖整个联合主键)而不能只依赖部分 + +3.第三范式:满足第二范式的前提上,要求非主键要直接依赖主键 + +注意:实际开发不会完全按照范式来设计,因为需求不一样,有时会故意反范式 \ No newline at end of file diff --git "a/33\351\227\253\347\273\247\345\221\250/\347\254\254\345\233\233\350\212\202\350\257\276\347\254\224\350\256\260.md" "b/33\351\227\253\347\273\247\345\221\250/\347\254\254\345\233\233\350\212\202\350\257\276\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..49f3ea4efd3468bc24a2b93f7334cd0689b92b69 --- /dev/null +++ "b/33\351\227\253\347\273\247\345\221\250/\347\254\254\345\233\233\350\212\202\350\257\276\347\254\224\350\256\260.md" @@ -0,0 +1,25 @@ +Visio制作ER图的一个软件: + +一个软件:power Designer + +第一步:创建概念模型(类似ER图)CDM(以用户的角度) + +第二步:转换成逻辑模型LDM (以计算机的角度) + +第三步:转换成物理模型 (以数据库角度) + + + +数据库设计步骤: + +1.需求分析 + +2.ER图 + +3.逻辑结构设计 + +4.物理模型设计 + +5.数据库的实施 + +6.数据库的维护 \ No newline at end of file