Database Design

Database Design Sequence

1. Requirement Analysis

 Understand what data is to store, what app is to be built and which operation are most frequent 

2. Conceptual Design

High-level description of data closely matching how users think of the data 

3. Logical Design

 Conceptual design into logical database schema 

4. Schema Design

   Identify problems into current schema & refine

5. Physical Design*

     Logical database schema into a physical schema for a specified DBMS 

6. App & Physical Design

Conceptual Database Design

  • Goal: Specify the database schema
  • Conceptual Database Design: A technique for understanding and capturing business information requirements graphically

Entity-Relationship Diagrams (ER Diagrams)

  • Entity: an individual object

  • Entity Set (entity type): a collection of entity that shares the common properties or characteristics

  • Attribute: describes one aspect of an entity set

Entity (实体) & Attribute (属性) 表示图形:

entity set 表示实体,例如students 学生
A1 到 An 表示基于该实体的Attribute(属性),例如学生的学生号码,名字,年龄,出生日期等
A1底下的横线表示该 Entity Set 的 Primary Key 
图片 Reference (The University of Sydney, 2020, Lecture 2 Power Point)

Entity 表示方法

  • Domain: possible value of an attribute

       Can be simple and composite attribute 
         (Composition Attribute 例如学生的 first name 和 last name 可以 combine 为学生的 name Attribute)
       Can be sing-valued and multi-valued attribute 
         (Multi-valued Attribute 允许存储多个value在同一个Attribute内部,例如学生可能拥有多个不同的Phone Number 和 Email)
       Double ellipses for multi-valued attribute 
       Dot ellipses for derived attribute
          (Derived Attribute 是派生的Attribute,例如如果知道学生的 date of birth 可以推测派生出学生的 age,age 就是 students 的 Derived Attribute)
    
  • Relationship: relates two or more entities

  • Relationship Type (Relationship Set): Set of relationships

     Diamond represents relationship type 
    

Relationship Between Student and Course:

 学生 Enrol 到不同的课程中,这个图展示了 Student 和 Course 的两个不同 Entity Set 之间的关系
 图片 Reference (The University of Sydney, 2020, Lecture 2 Power Point)

描述学生和course两个Entity的关系

Relationship 的类型:

   Employee 可能具备管理者和普通员工,所以 Employee 的实体集可以管理其自身
   两个实体集之间可以具备某种关系
   三个不同的实体集也可以具备同一个关系
   关系可以具备某个Attribute,例如学生(Entity Set)可被记录到某一天 Enroll 到某个课程(Entity Set)中
   图片 Reference (The University of Sydney, 2020, Lecture 2 Power Point)

Relationship 的类型

  • Week Entity Type: An entity type that does not have a self-contained primary key

  • Generalization: low-level of entity will inherence the attribute of high-level entity

Generalization 的表示方法:

    Child 会继承 Parent Entity Set 所存在的全部 Attribute。
    IsA 是用来展示 Generalization 的 Relationship 名称。
    Child 同样可以拥有自己特殊的 Attribute。
    图片 Reference (The University of Sydney, 2020, Lecture 2 Power Point)

继承图的样子

Logical Design

赞等更新

Schema Design

暂等更新

Physical Design

暂等更新

Relational Data Model

Concept: A database is a collection of one or more relations, where each relation is a table with rows and columns

SQL Language

DDL (Data Definitaion Language)

DDL: The subset of SQL that supports the creation, deletion and modification of tables.

SQL Code To Create Table:

 CREATE TABLE name ( list-of-columns);

Based Data Type to Support DDL Query:

 图片 Reference (The University of Sydney, 2020, Lecture 3 Power Point)

Data Type in DDL
SQL Code To Delete Table:

 DROP TABLE name;

SQL Code To Change Table:

 ALTER TABLE name ADD COLUMN … | ADD CONSTRAINT…| …
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值