Intro

SQL: 关系型数据库( MySQL, Teradata)
By the end of this course, you will know how to:

  1. Describe the structure of relational databases;

  2. Interpret and create entity-relationship diagrams and relational schemas that describe the contents of specific databases;

  3. Write queries that retrieve and sort data that meet specific criteria, and retrieve such data from MySQL and Teradata databases that contain over 1 million rows of data;

  4. Execute practices that limit the impact of your queries on other coworkers;

  5. Summarize rows of data using aggregate functions, and segment aggregations according to specified variables;

  6. Combine and manipulate data from multiple tables across a database;

  7. Retrieve records and compute calculations that are dependent on dynamic data features, and translate data analysis questions into SQL queries.

Week 1

How Relational Databases Help Solve Those Problems

关系型数据库的基本概念是 将数据集拆分为单独的数据片段或者子集 每一个数据子集都有一个主题, 这个主题在逻辑上将数据记录和 这个子集相绑定。在检索信息时,数据库只会和某些子集交互 这些子集提供了你想要的数据 而不是和整个数据库交互这一策略确保了数据只需要 尽可能少的空间去存储,同时让检索变快。
Managing Big Data with MySQL学习笔记

  • 单个表应表示数据集的最小逻辑部分
  • 表中的每一列 都必须表示唯一的 信息类别
  • 表中的每一行也必须表示该信息的唯一实例
  • 表中列的顺序或 行的顺序是无关紧要的 这将允许数据库按任意的, 它认定是最快的 顺序或样式将它们拉到一起

Database Design Tools

数据库设计和模型架构

  • Entity-Relationship Diagram
  • Relational Schemas

Entity-Relationship Diagram

这些表是通过一个或 多个具有相同值的列连接起来的。 通过这些列(的值),我们可以把不同表中的行数据关联起来。
Managing Big Data with MySQL学习笔记

  1. 实体(矩形)
    Managing Big Data with MySQL学习笔记
    正方形表示实体。 这些体现你在数据库中所保存数据的种类。 每个正方形是一个种类。 最后实现数据库的时候,每个实体大概率会成为表。

    双矩形表示Weak Entity

  2. 属性(椭圆)
    Managing Big Data with MySQL学习笔记
    每个数据种类 也就是实体需要记录的数据的一些具体的方面。 属性一般会体现在实体的 列。 实体关系图中的每一个属性至少要连接到某一个实体。 并且,根据集合理论,每个属性在实体中 必须唯一。

每一条收集到的某一个实体的数据, 称为该实体的实例 Entity Instance。 实体的实例可以看成是数据表中的

实体中最重要的属性在每个实例都拥有 唯一的值 正式名称叫做唯一属性 Unique Attribute。 也有的时候称之为唯一键或者唯一标识符。是每一行数据具有不同唯一值的列, 每个实体必须至少有一个属性作为唯一键或 标识符。用加下划线表示。

可以被其他属性组合重新创建的属性用 ( ) 修饰 Composite Attribute

Partial Key == 虚线 == 修饰这个属性无法identify它从属的entity。必须结合其他属性才能完成identify

  1. 实体之间的关系(菱形)
    每个实体或 类别必须与数据库中的至少一个其他实体相关。 您使用菱形和线条来表述这些关系。 菱形里填写关系的本质
    Managing Big Data with MySQL学习笔记
    接近矩形的符号表示实例的最大数目 这个数是实体可以和其他实体 相关联的实例的最大数字 与矩形距离较远的符号则表示 实体A中可以与实体B关联的最小的实例数目。

Managing Big Data with MySQL学习笔记

Relational Schemas

Managing Big Data with MySQL学习笔记
Managing Big Data with MySQL学习笔记

Components of Relational Schema:

  • Table

Managing Big Data with MySQL学习笔记

row and column without order.

  • Primary key

Managing Big Data with MySQL学习笔记

Different from unique columns in Relational schemas.
  • Foreign key
    Link table to another table.

Managing Big Data with MySQL学习笔记

相关文章: