diff --git "a/35 \347\224\260\351\233\252\347\220\274/20230910 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" "b/35 \347\224\260\351\233\252\347\220\274/20230910 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.txt" similarity index 97% rename from "35 \347\224\260\351\233\252\347\220\274/20230910 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" rename to "35 \347\224\260\351\233\252\347\220\274/20230910 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.txt" index ea10775957bf864b03e12f0b9973f5adab7aa74f..b81d42c2a8c1529ef80e6469e54453b19a30207c 100644 --- "a/35 \347\224\260\351\233\252\347\220\274/20230910 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" +++ "b/35 \347\224\260\351\233\252\347\220\274/20230910 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.txt" @@ -1,194 +1,194 @@ -# 笔记 -建模 - -1概念模型:CDM ER图、人类角度 - -2.逻辑模型:LDM 计算机 - -3.物理模型:PDM 从具体数据库角度 - -4.生成DDL - -# 作业 - -```mysql -/*==============================================================*/ -/* DBMS name: MySQL 5.0 */ -/* Created on: 2023/9/9 13:52:45 */ -/*==============================================================*/ - - -CREATE DATABASE Book CHARSET utf8; -use Book; -drop table if exists book; - -drop table if exists borrow; - -drop table if exists giveBack; - -drop table if exists store; - -drop table if exists system; - -drop table if exists type; - -drop table if exists user; - -/*==============================================================*/ -/* Table: book */ -/*==============================================================*/ -create table book -( - b_id varchar(4) not null, - type_id int, - b_name varchar(8) not null, - b_writer varchar(8) not null, - b_press varchar(8) not null, - b_date varchar(12) not null, - b_price decimal(5,2) not null, - primary key (b_id) -); -INSERT INTO book VALUES -('001',1,'红楼梦','曹雪芹','人民文学出版社','2008年7月1日',51.5), -('002',2,'格林童话','格林兄弟','吉林美术出版社','2019年4月',38.9), -('003',3,'法医秦明','秦明','江苏文艺出版社','2020年10月',49.8); - - - -/*==============================================================*/ -/* Table: borrow */ -/*==============================================================*/ -create table borrow -( - borrow_id int not null auto_increment, - u_id int, - b_id varchar(4), - borrow_amout int not null, - borrow_date date not null, - borrow_time varchar(8) not null, - borrow_end date not null, - primary key (borrow_id) -); -INSERT INTO borrow VALUES -(1,1,'001',1,'2023-9-1','20天','2023-9-21'), -(2,3,'002',2,'2023-9-2','15天','2023-9-17'), -(3,2,'003',3,'2023-9-3','25天','2023-9-28'); - -/*==============================================================*/ -/* Table: giveBack */ -/*==============================================================*/ -create table giveBack -( - giveBack_id int not null auto_increment, - u_id int, - b_id varchar(4), - giveBack_amount int not null, - giveBack_date date not null, - primary key (giveBack_id) -); -INSERT into giveBack VALUES -(1,2,'001',1,'2023-9-20'), -(2,1,'003',3,'2023-9-25'), -(3,3,'002',4,'2023-9-30'); - -/*==============================================================*/ -/* Table: store */ -/*==============================================================*/ -create table store -( - s_id int not null auto_increment, - b_id varchar(4), - s_floor int not null, - s_area varchar(4) not null, - s_pressmark varchar(4) not null, - s_tier int not null, - primary key (s_id) -); -INSERT INTO store VALUES -(null,'001',3,'1区','01',2), -(null,'003',4,'2区','02',3), -(null,'002',5,'3区','03',4); - - -/*==============================================================*/ -/* Table: system */ -/*==============================================================*/ -create table system -( - system_id int not null auto_increment, - u_id int, - system_name varchar(12) not null, - system_amount int not null, - system_time varchar(8) not null, - system_price decimal not null, - primary key (system_id) -); -INSERT INTO system VALUES -(1,3,'普通会员',20,'1个月',30), -(2,1,'vip会员',35,'2个月',55), -(3,2,'svip会员',20,'3个月',75); - - - -/*==============================================================*/ -/* Table: type */ -/*==============================================================*/ -create table type -( - type_id int not null, - b_id varchar(4), - type_name varchar(8) not null, - primary key (type_id) -); -insert into type VALUES -(1,'001','文学类'), -(2,'002','少儿类'), -(3,'003','悬疑类'); - - -/*==============================================================*/ -/* Table: user */ -/*==============================================================*/ -create table user -( - u_id int not null auto_increment, - u_name varchar(4) not null, - u_sex varchar(4) not null, - u_age int not null, - u_tel varchar(12) not null, - primary key (u_id) -); -INSERT into user VALUES -(1,'张三','男',18,'15107465789'), -(2,'李四','女',19,'18234567891'), -(3,'王五','男',18,'13342849002'); - - - -alter table book add constraint FK_Relationship_4 foreign key (type_id) - references type (type_id) on delete restrict on update restrict; - -alter table borrow add constraint FK_ި˩ foreign key (b_id) - references book (b_id) on delete restrict on update restrict; - -alter table borrow add constraint FK_ި˩ԃۧ foreign key (u_id) - references user (u_id) on delete restrict on update restrict; - -alter table giveBack add constraint FK_Relationship_3 foreign key (u_id) - references user (u_id) on delete restrict on update restrict; - -alter table giveBack add constraint FK_۹˩ foreign key (b_id) - references book (b_id) on delete restrict on update restrict; - -alter table store add constraint FK_Relationship_1 foreign key (b_id) - references book (b_id) on delete restrict on update restrict; - -alter table system add constraint FK_Relationship_5 foreign key (u_id) - references user (u_id) on delete restrict on update restrict; - -alter table type add constraint FK_Relationship_2 foreign key (b_id) - references book (b_id) on delete restrict on update restrict; -select * from user; -select * from borrow; -select * from user,borrow where user.u_id = borrow.u_id; +# 笔记 +建模 + +1概念模型:CDM ER图、人类角度 + +2.逻辑模型:LDM 计算机 + +3.物理模型:PDM 从具体数据库角度 + +4.生成DDL + +# 作业 + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/9 13:52:45 */ +/*==============================================================*/ + + +CREATE DATABASE Book CHARSET utf8; +use Book; +drop table if exists book; + +drop table if exists borrow; + +drop table if exists giveBack; + +drop table if exists store; + +drop table if exists system; + +drop table if exists type; + +drop table if exists user; + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + b_id varchar(4) not null, + type_id int, + b_name varchar(8) not null, + b_writer varchar(8) not null, + b_press varchar(8) not null, + b_date varchar(12) not null, + b_price decimal(5,2) not null, + primary key (b_id) +); +INSERT INTO book VALUES +('001',1,'红楼梦','曹雪芹','人民文学出版社','2008年7月1日',51.5), +('002',2,'格林童话','格林兄弟','吉林美术出版社','2019年4月',38.9), +('003',3,'法医秦明','秦明','江苏文艺出版社','2020年10月',49.8); + + + +/*==============================================================*/ +/* Table: borrow */ +/*==============================================================*/ +create table borrow +( + borrow_id int not null auto_increment, + u_id int, + b_id varchar(4), + borrow_amout int not null, + borrow_date date not null, + borrow_time varchar(8) not null, + borrow_end date not null, + primary key (borrow_id) +); +INSERT INTO borrow VALUES +(1,1,'001',1,'2023-9-1','20天','2023-9-21'), +(2,3,'002',2,'2023-9-2','15天','2023-9-17'), +(3,2,'003',3,'2023-9-3','25天','2023-9-28'); + +/*==============================================================*/ +/* Table: giveBack */ +/*==============================================================*/ +create table giveBack +( + giveBack_id int not null auto_increment, + u_id int, + b_id varchar(4), + giveBack_amount int not null, + giveBack_date date not null, + primary key (giveBack_id) +); +INSERT into giveBack VALUES +(1,2,'001',1,'2023-9-20'), +(2,1,'003',3,'2023-9-25'), +(3,3,'002',4,'2023-9-30'); + +/*==============================================================*/ +/* Table: store */ +/*==============================================================*/ +create table store +( + s_id int not null auto_increment, + b_id varchar(4), + s_floor int not null, + s_area varchar(4) not null, + s_pressmark varchar(4) not null, + s_tier int not null, + primary key (s_id) +); +INSERT INTO store VALUES +(null,'001',3,'1区','01',2), +(null,'003',4,'2区','02',3), +(null,'002',5,'3区','03',4); + + +/*==============================================================*/ +/* Table: system */ +/*==============================================================*/ +create table system +( + system_id int not null auto_increment, + u_id int, + system_name varchar(12) not null, + system_amount int not null, + system_time varchar(8) not null, + system_price decimal not null, + primary key (system_id) +); +INSERT INTO system VALUES +(1,3,'普通会员',20,'1个月',30), +(2,1,'vip会员',35,'2个月',55), +(3,2,'svip会员',20,'3个月',75); + + + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + type_id int not null, + b_id varchar(4), + type_name varchar(8) not null, + primary key (type_id) +); +insert into type VALUES +(1,'001','文学类'), +(2,'002','少儿类'), +(3,'003','悬疑类'); + + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table user +( + u_id int not null auto_increment, + u_name varchar(4) not null, + u_sex varchar(4) not null, + u_age int not null, + u_tel varchar(12) not null, + primary key (u_id) +); +INSERT into user VALUES +(1,'张三','男',18,'15107465789'), +(2,'李四','女',19,'18234567891'), +(3,'王五','男',18,'13342849002'); + + + +alter table book add constraint FK_Relationship_4 foreign key (type_id) + references type (type_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_ި˩ foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_ި˩ԃۧ foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table giveBack add constraint FK_Relationship_3 foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table giveBack add constraint FK_۹˩ foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table store add constraint FK_Relationship_1 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table system add constraint FK_Relationship_5 foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table type add constraint FK_Relationship_2 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; +select * from user; +select * from borrow; +select * from user,borrow where user.u_id = borrow.u_id; ``` \ No newline at end of file diff --git "a/35 \347\224\260\351\233\252\347\220\274/20230912 \350\261\206\347\223\243\347\224\265\345\275\261.md" "b/35 \347\224\260\351\233\252\347\220\274/20230912 \350\261\206\347\223\243\347\224\265\345\275\261.md" new file mode 100644 index 0000000000000000000000000000000000000000..48378c621323d7c36aa6e41b5ad19d0d631e4651 --- /dev/null +++ "b/35 \347\224\260\351\233\252\347\220\274/20230912 \350\261\206\347\223\243\347\224\265\345\275\261.md" @@ -0,0 +1,158 @@ +笔记 +1.回顾图书管理系统加强表与表之间的关系,开展豆瓣电影 +# 作业 + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/12 10:27:43 */ +/*==============================================================*/ +CREATE DATABASE movie charset utf8; +use movie; + +drop table if exists country; + +drop table if exists job; + +drop table if exists language; + +drop table if exists movieman; + +drop table if exists movie; + +drop table if exists movietype; + +drop table if exists review; + +/*==============================================================*/ +/* Table: country */ +/*==============================================================*/ +create table country +( + c_id char(10) not null, + m_id int, + c_name char(10) not null, + primary key (c_id) +); + +-- 插入数据 +INSERT INTO country +VALUES + ( 1, '1', '美国' ), + ( 2, '1', '韩国' ); + +/*==============================================================*/ +/* Table: job */ +/*==============================================================*/ +create table job +( + j_id int not null auto_increment, + m_id int, + j_name varchar(5) not null, + primary key (j_id) +); +INSERT INTO job +VALUES + ( 1, 1, '编剧' ), + ( 3, 1, '主演' ), + ( 2, 1, '导演' ); +/*==============================================================*/ +/* Table: language */ +/*==============================================================*/ +create table language +( + l_id int not null auto_increment, + m_id int, + l_name varchar(5) not null, + primary key (l_id) +); +INSERT INTO LANGUAGE +VALUES + ( 1, 1, '英语' ), + ( 2, 1, '韩语' ); +/*==============================================================*/ +/* Table: moiveman */ +/*==============================================================*/ +create table movieman +( + mp_id int not null auto_increment, + j_id int, + mp_name varchar(10) not null, + primary key (mp_id) +); +INSERT INTO movieman +VALUES + ( NULL, 1, '席琳.宋' ), + ( NULL, 2, '席琳.宋' ), + ( NULL, 3, '格蕾塔.李' ), + ( NULL, 3, '刘台午' ), + ( NULL, 3, '约翰.马加罗' ), + ( NULL, 3, '文胜雅' ), + ( NULL, 3, '尹智慧' ); +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + m_id int not null auto_increment, + m_name varchar(10) not null, + m_time varchar(5) not null, + m_otname varchar(20) not null, + m_opentime date not null, + IMDB varchar(10) not null, + primary key (m_id) +); +INSERT INTO `movie`.`movie` ( `m_id`, `m_name`, `m_time`, `m_otname`, `m_opentime`, `IMDB` ) +VALUES + ( 1, '过往人生', '106分钟', '前世因缘', '2023-06-02', 'tt13238346' ); +/*==============================================================*/ +/* Table: movietype */ +/*==============================================================*/ +create table movietype +( + mt_id int not null auto_increment, + m_id int, + mt_name varchar(10) not null, + primary key (mt_id) +); +INSERT INTO movietype +VALUES + ( 1, 1, '剧情/爱情' ); +/*==============================================================*/ +/* Table: review */ +/*==============================================================*/ +create table review +( + r_id int not null auto_increment, + r_name varchar(10) not null, + m_id int, + r_a varchar(200) not null, + primary key (r_id) +); +INSERT INTO review +VALUES + ( 1, '烤芬', 1, '符合预期的A24小布尔乔亚电影,前三分之二都挺无聊,但最终确实成功抵达了某些具体的隐痛。我看 Hae Sung 并不是个具体的人,而是象征故土的引诱:在移民的历程里,故土犹如童年的爱人在寂寞时给予陪伴、反复召唤你的回归、描绘与他可以随时重建某种更亲密关系的可能、暗示你们的联系才是更本真更深刻的;因此,移民在一生中要周期性与故土诀别,并每次都为诀别所伤。观看途中我一直在想四年级时全家移民加拿大的小学' ), + ( 2, 'Seb’s', 1, '感觉男主更多是女主东亚identity的symbol,女主移民两次,不可能抛下一切回到故土,都为了绿卡提早结婚了诶,但本源文化又一直在那里,真遇到也会舒适。男主真的好东亚啊,咱东亚人地铁上手可以精确到0.001毫米不碰到一起,临行可以深情对望108分钟,初恋可以记着20多年,苦笑着说加班不给钱,指了指自己的脑袋说我精神很强大,东亚人有点苦' ), + ( 3, '十二辰子', 1, '想想自己都没有这样一个可以永远怀念的人,也真是有点遗憾啊' ); + +alter table country add constraint FK_Relationship_5 foreign key (m_id) + references movie (m_id) on delete restrict on update restrict; + +alter table job add constraint FK_Relationship_3 foreign key (m_id) + references movie (m_id) on delete restrict on update restrict; + +alter table language add constraint FK_Relationship_4 foreign key (m_id) + references movie (m_id) on delete restrict on update restrict; + +alter table moiveman add constraint FK_Relationship_1 foreign key (j_id) + references job (j_id) on delete restrict on update restrict; + +alter table movietype add constraint FK_Relationship_2 foreign key (m_id) + references movie (m_id) on delete restrict on update restrict; + +alter table review add constraint FK_Relationship_6 foreign key (m_id) + references movie (m_id) on delete restrict on update restrict; + + +``` +