Introduction

为什么要使用数据库?

如果使用普通的文件文件存储数据,以 CSV 文件格式为例,

Database Management System (DBMS)

A software pieces that allow you to store, analyze and manipulate data in a database.

Data Models

A data model is a collection of concepts for describing the data in a database.

A schema is a description of a particular collection of data with a given data model.

Most:

NoSQL:

Machine Learning:

Obsolete / Legacy:


Relational Model

Key tenets:

relation

即常说的(,Table,)

元组(,Tuple,)

即表中的一行数据

主键(,Primary Keys,)

表中对每一个元组的唯一标识符

外键(,Foreign Keys,)

在一个表中用于关联另一个表中数据的键

Relational Algebra

Relational algebra operators:

Extra operators:

Each operator takes one or more relations as inputs and outputs a new relation.

OperatorDescription
Select从表中根据一些特定条件选出一个子集(,Choose a subset of the tuples from a relation that satisfies a selection predicate,)
Projection从表中选出特定几个列,组成新表(,Generate a relation with tuples that contains only the specified attributes,)
Union选取数个表,返回其合并后产生的新表(,Generate a relation that contains all tuples that appear in either only one or both input relations,)
Intersection选取数个表,返回其取交集产生的新表(,Generate a relation that contains only the tuples that appear in both of the input relations.,)
Difference对两个表,返回在第一个表中,第二个表中没有出现的元组组成的新表(,Generate a relation that contains only the tuples that appear in the first and not the second of the input relations.,)
Product返回由两个表中所有元组的所有组合组成的新表(,Generate a relation that contains all possible combinations of tuples from the input relations,)
Join通过另一个表的数据作为条件来查询一个表中的数据(,Generate a relation that contains all tuples that are a combination of two tuples (one from each input relation) with a common value(s) for one or more attributes,)tes)

点此查看原文