-
第一范式
数据表中的字段都是不可再分的原子值。
-
第二范式
在满足第一范式的条件下,除主键外的字段都必须完全依赖与主键。
不满足第二范式:
create table order(
product_id int,
customer_id int,
product_name varchar(20),
customer_name varchar(20),
primary key(product_id ,customer_id )
);
满足第二范式:
create table order(
order_id int primary key,
product_id int,
customer_id int,
);
create table product(
product_id int primary key,
product_name varchar(20)
);
create table customer(
customer_id int primary key,
customer_name varchar(20)
);
-
第二范式
满足第二范式的条件下,除主键外的字段之间不能有传递依赖关系。
不满足第三范式:
create table order(
order_id int primary key,
product_id int,
customer_id int,
customer_phone int
);
create table product(
product_id int primary key,
product_name varchar(20)
);
create table customer(
customer_id int primary key,
customer_name varchar(20)
);
满足第三范式:
create table order(
order_id int primary key,
product_id int,
customer_id int
);
create table product(
product_id int primary key,
product_name varchar(20)
);
create table customer(
customer_id int primary key,
customer_name varchar(20),
customer_phone int
);