当前位置: 首页 > news >正文

东南大学数据库课程06-Database Design

Database Design

目录
  • Database Design
  • Data Dependency
  • Normalization of Relational Schema
    • 1NF
    • 2NF
    • Problems of non 2NF
    • 3NF
    • Problems of non 3NF
    • Summary
  • ER Model and ER Diagram
  • Database Design Method
    • Requirement Analysis
    • Concept Design
    • Logic Design
    • Physical Design
  • Summary

Data Dependency

Some dependent relations exit between attributes

  1. Function dependency(FD): the most basic kind of data dependencies. The value of one or a group attributes can decide the value of other attributes. FD is the most important in general database design.(学号可以决定其他属性的值,其他属性是函数依赖与学号的)

  2. Multi-valued Dependency(MVD):the value of some attribute can decide a group of values of some other attributes. (函数依赖是多值依赖的特例;决定一个值\决定一组值)

  3. Join Dependency (JD): the constraint of lossless join decomposition.

    SPJ(供应商,零件,项目)

    SPJ[S,P,J] = SPJ[S,P] join SPJ[S,J] join SPJ[p,j]
    无损连接分解
    SPJ三个属性存在连接依赖

Normalization of Relational Schema

1NF

every attribute of a relation must be atomic.(不允许表中套表)

8ebcf975-ddea-4ca8-b037-be2fa780c87f

2NF

  1. R∈1NF
  2. no partially function dependency exists between attributes.(不存在属性对主键的部分函数依赖

图56.png

S(S#, SNAME, AGE, ADDR, C#, GRADE)
--- non 2NF

(S,C)是主键,S可以决定SNAME,AGE,ADDR。三者对主键存在部分函数依赖,不属于2NF

Problems of non 2NF

  • Insert abnormity: can not insert the students’
    information who have not selected course.【因为SC都是主键】
  • Delete abnormity: if a student unselect all courses, his
    basic information is also lost.【C是主键,存在实体性约束】
  • Hard to update: because of redundancy, it is hard to
    keep consistency when update.【比如一个学生选了50门课,那么它的基本信息没有必到地存了50次,这个更新带来了麻烦】

Resolving:
According to the rule of “one fact in one place”【一事一地的原则】 to decompose the relation into 2 new relations:
S(S#, SNAME, AGE, ADDR)
SC(S#, C#, GRADE)

3NF

  1. R∈2NF
  2. no transfer function dependency exists between attributes.【属性对主键没有传递依赖】

EMP(EMP#, SAL_LEVEL, SALARY)
--- non 3NF

【SALARY依赖于SAL_LEVEL,SALE_LEVEL依赖于EMP】

Problems of non 3NF

  • Insert abnormity: before the employees’s sal_level are
    decided, the correspondence between sal_level and
    salary can not input.
  • Delete abnormity: if some sal_level has only one man,
    the correspondence between sal_level and salary of
    this level will be lost when the man is deleted.
  • Hard to update: because of redundancy, it is hard to
    keep consistency when update.【SALE_LEVEL和SALE只需要知道一个,冗余了】

Resolving:
According to the rule of “one fact in one place” to
decompose the relation into 2 new relations:
EMP(EMP#,SAL_LEVEL)
SAL(SAL_LEVEL,SALARY

Summary

图57.png

一般到3NF即可,必要时会根据实际情况逆范式。基本原则是“一事一地”

ER Model and ER Diagram

d66997d5-4ee4-47e4-9188-e0c4076f2ee7

Database Design Method

  • Procedure oriented method[类似于面向过程]
    This method takes business procedures as center, the database
    schema is designed basically in accordance directly with the
    vouchers, receipts, reports, etc. in business. Because of no
    detailed analysis on data and inner relationships between data,
    although it is fast at the beginning of the project, it is hard to
    ensure software quality and the system will be hard to fit future
    changes in requirement and environment. So this method is not
    suitable for the development of a large, complex system.
  • Data oriented method[类似于面向对象]
    This method design the database schema based on the detailed
    analysis on data and inner relationships between data which are
    involved in business procedures. It takes data as center, not
    procedures. It can not only fulfill the current requirements, but
    also some potential requirements. It is liable to fit future changes
    in requirement and environment. It is recommended in the
    development of large, complex systems

41bff2f5-310b-4b5a-acf8-ba44caba3c67

Requirement Analysis:定义数据字典,DFD(数据流图)

Concept Desing:画出ER图,与具体的DBMS无关

Logic Design:将er图转换为具体的表

Physical Design:物理实现

Requirement Analysis

A very important part of system requirement analysis. In requirement analysis phase, the data dictionary and DFD (or UML) diagrams are the most important to database design.

Dictionary and DFD

  • Name confilicts

    ➢ Homonym(the same name with different meanings)
    ➢ Synonym(the same meaning in different names)

  • Concpet confilicts

    dept在一个表中是一个属性,在另一个表中是一个实体

  • Domain conflicts

    性别的取值:男女,0,1,MW

About coding
➢ Standardization of information
➢ Identifying entities
➢ Compressing【压缩】 information

Through requirement analysis, all information must be with unique source and unique responsibility

Concept Design

70ad78cf-404a-4a0a-bd02-e567309d6555

Logic Design

从此处开始都是技术活儿了,与甲方无关了

denormalization:逆范式

denormalization:逆范式

Physical Design

227da5cb-f412-4f8c-96d4-59915334a29e

Summary

本质:原子数据

本质:原子数据

https://www.bilibili.com/video/BV1Xt4y1L7S1/?spm_id_from=333.1007.tianma.1-1-1.click

http://www.wxhsa.cn/company.asp?id=4721

相关文章:

  • MacOS升级15.2后的问题(二):无法修改mac网络地址
  • 东南大学数据库课程07-Distributed Database Systems
  • HCIA——VLAN间通信
  • Xdebug安装与PhpStorm调试配置
  • vue - 内置指令
  • 东南大学数据库课程02-DataModel数据模型
  • Torch核心数据结构Tensor(张量)
  • vue - 进阶
  • 读书笔记:为什么你的数据库有时不用索引?一个关键参数告诉你答案
  • MacOS升级15.2后的问题(一):安装第三方下载的软件,提醒文件已损坏
  • Playwright MCP浏览器自动化教程
  • 故障分析:ORA-00900 修改props$中字符集导致
  • 实用指南:Flask学习笔记(三)--URL构建与模板的使用
  • Ollama + Python 极简工作流
  • 快速搞定Dify+Chrome MCP:打造能操作网页的AI助手
  • HCIP——RSTP
  • ORA-01555系列:三、ORA-01555总结与高级优化建议
  • Unstable Twin - TryHackMe
  • 单片机实现挡位调节
  • 完整教程:从 WildCard 野卡到 gptplus.plus:一次解决 OpenAI 支付难题的实战复盘,轻松搞定Gpt充值
  • 阿里 Qoder 新升级,Repo Wiki 支持共享、编辑和导出
  • 长城杯WriteUp
  • vite取别名@
  • JavaScript数据网格方案AG Grid 34.2 发布:更灵活的数据结构、更流畅的大数据交互与全新 UI 体验
  • BOE(京东方)IPC电竞嘉年华盛典圆满收官 第三届无畏杯总决赛引领电竞生态发展热潮
  • P1886 滑动窗口 /【模板】单调队列
  • kingbase金仓数据库docker部署完整步骤
  • glTF/glb功能、应用和 5 个基本最佳实践
  • AI 应用开发,不就是调个接口么?
  • 95.费解的开关