diff --git "a/\345\273\226\346\263\260\347\216\256/20240904/CDM.png" "b/\345\273\226\346\263\260\347\216\256/20240904/CDM.png" new file mode 100644 index 0000000000000000000000000000000000000000..d16f6c0fd39e32ffc428653ce7939c3cb4303d1d Binary files /dev/null and "b/\345\273\226\346\263\260\347\216\256/20240904/CDM.png" differ diff --git "a/\345\273\226\346\263\260\347\216\256/20240904/LDM.png" "b/\345\273\226\346\263\260\347\216\256/20240904/LDM.png" new file mode 100644 index 0000000000000000000000000000000000000000..bf7bef59efbd4608116ec035443af21f0bb67873 Binary files /dev/null and "b/\345\273\226\346\263\260\347\216\256/20240904/LDM.png" differ diff --git "a/\345\273\226\346\263\260\347\216\256/20240904/PDM.png" "b/\345\273\226\346\263\260\347\216\256/20240904/PDM.png" new file mode 100644 index 0000000000000000000000000000000000000000..943bc60ba3e7fed6ed6325d09e69d31b1a3601ff Binary files /dev/null and "b/\345\273\226\346\263\260\347\216\256/20240904/PDM.png" differ diff --git "a/\345\273\226\346\263\260\347\216\256/20240904/crebas.sql" "b/\345\273\226\346\263\260\347\216\256/20240904/crebas.sql" new file mode 100644 index 0000000000000000000000000000000000000000..da217fbe4fbccc0d40e44db4b435a7b19d6af6e3 --- /dev/null +++ "b/\345\273\226\346\263\260\347\216\256/20240904/crebas.sql" @@ -0,0 +1,88 @@ +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/4 21:26:35 */ +/*==============================================================*/ + + +drop table if exists game; + +drop table if exists pael; + +drop table if exists paelman; + +drop table if exists sxx; + +drop table if exists uerl; + +/*==============================================================*/ +/* Table: game */ +/*==============================================================*/ +create table game +( + g_id int not null, + g_name varchar(10), + primary key (g_id) +); + +/*==============================================================*/ +/* Table: pael */ +/*==============================================================*/ +create table pael +( + g_id int not null, + p_id int not null, + primary key (g_id, p_id) +); + +/*==============================================================*/ +/* Table: paelman */ +/*==============================================================*/ +create table paelman +( + p_id int not null, + s_id int, + p_name varchar(10), + primary key (p_id) +); + +/*==============================================================*/ +/* Table: sxx */ +/*==============================================================*/ +create table sxx +( + s_id int not null, + s_ma varchar(18), + name varchar(10), + primary key (s_id) +); + +/*==============================================================*/ +/* Table: uerl */ +/*==============================================================*/ +create table uerl +( + u_id int not null, + p_id int, + u_name varchar(18), + primary key (u_id) +); + +alter table pael add constraint FK_pael foreign key (g_id) + references game (g_id) on delete restrict on update restrict; + +alter table pael add constraint FK_pael2 foreign key (p_id) + references paelman (p_id) on delete restrict on update restrict; + +alter table paelman add constraint FK_haye foreign key (s_id) + references sxx (s_id) on delete restrict on update restrict; + +alter table uerl add constraint FK_have foreign key (p_id) + references paelman (p_id) on delete restrict on update restrict; + +INSERT INTO game VALUES (1,"wz"),(2,"ys"),(3,"mc"); +INSERT INTO pael VALUES (1,2),(2,2),(3,1); +INSERT INTO paelman VALUES (1,1,"zs"),(2,2,"ls"); +INSERT INTO sxx VALUES (1,1884562456,"zs"),(2,46415115,"ls"); +INSERT INTO uerl VALUES (1,1,"46646"),(2,1,"4684668"),(3,2,"486456"); + +SELECT * FROM uerl as u,paelman as p WHERE u.p_id=p.p_id; \ No newline at end of file diff --git "a/\345\273\226\346\263\260\347\216\256/20240904/\347\254\224\350\256\260.md" "b/\345\273\226\346\263\260\347\216\256/20240904/\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..3e9de9145a12e0d140b1db2fcf75ee75555c81f8 --- /dev/null +++ "b/\345\273\226\346\263\260\347\216\256/20240904/\347\254\224\350\256\260.md" @@ -0,0 +1,8 @@ +##表与表的关系## + 1. 一对一联系(1:1):一个实体的每个实例只关联另一个实体的一个实例。 + 2. 一对多联系(1:n):一个实体的每个实例可以关联另一个实体的多个实例。 + 3. 多对多联系(m:n):两个实体的多个实例之间可以相互关联。 +##三大范式## + 1. 第一范式(1NF): 确保每个字段只有单一的原子值,不允许重复的组。 + 2. 第二范式(2NF): 确保每个非主属性完全依赖于主键,消除部分依赖。 + 3. 第三范式(3NF): 确保每个非主属性直接依赖于主键,消除传递依赖。 \ No newline at end of file