数据表设计思想,ER图及三范式

数据表设计思想

设计流程

需求分析:根据用户的需求,分析出需要记录的数据

需求设计:根据分析出的数据,设计E-R模型图

详细设计:将E-R模型图转换成数据表

三大范式:使用数据库三大范式的设计思想对数据表进行审核

E-R模型图

概念:Entity-Relationship,实体关系图

组成元素:

举例,将下面三张表用E-R模型图表示出来

三大范式

概念:三大范式是数据库的一种设计规范,主要用来检查我们的数据库是否存在冗余数据。

第一范式:每一列都具有原子性,也就是不能再分割

第二范式:要求每一个表,只描述一件事情

第三范式:要求表中不存在冗余字段

create table Score

(

         sId int primary key auto_increment,

         studentId int not null,

         english float,

         math float

)

create table teacher

(

         tId int auto_increment primary key,

         tName varchar(50) not null,

         tSex char(2),

         tAge int,

         tSalary decimal

)

create table Class

(

         cId int auto_increment primary key,

         cName nvarchar(50) not null,

         cDesciption text

)

create table Student

(

         SId int auto_increment primary key,

         SName varchar(50),

         SGender char(2) not null,

         SAddress varchar(300),

         SPhone varchar(100),

         SAge int,

         SBirthday datetime,

         SCardId varchar(18) null,

         SClassId int not null

)

数据表设计思想

设计流程

需求分析:根据用户的需求,分析出需要记录的数据

需求设计:根据分析出的数据,设计E-R模型图

详细设计:将E-R模型图转换成数据表

三大范式:使用数据库三大范式的设计思想对数据表进行审核

E-R模型图

概念:Entity-Relationship,实体关系图

组成元素:

举例,将下面三张表用E-R模型图表示出来

三大范式

概念:三大范式是数据库的一种设计规范,主要用来检查我们的数据库是否存在冗余数据。

第一范式:每一列都具有原子性,也就是不能再分割

第二范式:要求每一个表,只描述一件事情

第三范式:要求表中不存在冗余字段

create table Score

(

         sId int primary key auto_increment,

         studentId int not null,

         english float,

         math float

)

create table teacher

(

         tId int auto_increment primary key,

         tName varchar(50) not null,

         tSex char(2),

         tAge int,

         tSalary decimal

)

create table Class

(

         cId int auto_increment primary key,

         cName nvarchar(50) not null,

         cDesciption text

)

create table Student

(

         SId int auto_increment primary key,

         SName varchar(50),

         SGender char(2) not null,

         SAddress varchar(300),

         SPhone varchar(100),

         SAge int,

         SBirthday datetime,

         SCardId varchar(18) null,

         SClassId int not null

)

猜你喜欢

转载自blog.csdn.net/fengxiaolu311/article/details/82716697