当前位置: 首页 > 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.rkmt.cn/news/5213.html

相关文章:

  • 东南大学数据库课程07-Distributed Database Systems
  • Xdebug安装与PhpStorm调试配置
  • 快速搞定Dify+Chrome MCP:打造能操作网页的AI助手
  • Unstable Twin - TryHackMe
  • 完整教程:从 WildCard 野卡到 gptplus.plus:一次解决 OpenAI 支付难题的实战复盘,轻松搞定Gpt充值
  • BOE(京东方)IPC电竞嘉年华盛典圆满收官 第三届无畏杯总决赛引领电竞生态发展热潮
  • 95.费解的开关
  • Spotify 音乐ML练习数据集含158 个特征,11
  • 最新药物数据集下载:来自Drugs
  • 400小时大规模南昌方言数据集助力方言保护、AI语音识别技术开发与文化传承研究,覆盖多样化场景与说话者,专业采集高质量音频与文本标注,支持深度学习、语音模型训练、方言教学工具及本地化智能语音交互应用
  • 350+张高清晰度冲积土、黑土、煤渣土、红土四类土壤类型图像资源 ,专为计算机视觉算法训练与地球科学研究设计,支持精准农业土壤识别、地质勘探辅助分析及环境监测应用,提升土壤分类模型准确性
  • 阶跃星辰开源Step-Video-T2V模型:300亿参数打造高保真视频生成新标杆
  • 多多报销小程序系统详解
  • 第0章 矿卡EBAZ4203爆改zynq开发板介绍和VIVADO的安装
  • 无痕检测是否注册iMessage服务,iMessages数据筛选,iMessage蓝号检测协议
  • Thundbird无法获取自签证书。
  • Gitee推出SBOM扫描功能:为开源供应链安全构筑数字防火墙
  • mysql连表查询,轻松掌握多表数据关联技巧
  • Qt-捕获摄像头画面
  • .NET驾驭Word之力:COM组件二次开发全攻略之连接Word与创建你的第一个自动化文档
  • 用户沉默之日,产品衰亡之时:逃离迭代中的“沉默陷阱”
  • 从工具到生态:现代Bug管理系统的平台化转型之路
  • JavaWeb基础
  • uni-app项目支付宝端Input不受控
  • 开启研究生学习阶段
  • 李航统计学习方法第二版 学习笔记
  • 如何拥有自己的一台永久免费云主机/云服务器
  • 发现一个新的资源论坛 - 小小程序员
  • 深入解析:Unity:XML笔记(二)——Xml序列化、反序列化、IXmlSerializable接口
  • C# Avalonia 13- MoreDrawing - CustomPixelShader