跳转至

Chapter 1: Introduction

1. Three Aspects to study Database

  • 1.Modeling and design of databases.
    • Get (abstract) data models from real world, then translate them into the forms suitable for the target DBMS (Database Management System) - tables, views.
  • 2.Programming: use database
    • queries and update of data.
  • 3.DBMS implementation
    • how does DBMS work, and how to design a DBMS.

两种访问数据库的方法

  • 方法1:利用数据库管理系统提供的交互工具访问数据库
  • 方法2:利用开发工具设计界面、处理数据,调用ODBC访问数据库,如ASP,JSP,VC++,PHP,PowerBuilder,Delphi

2. The definition of database

Database:

  • A collection of interrelated data, relevant to an enterprise.
  • A large collection of integrated and persistent data (DB). [R. Ramakrishnan, J. Gehrhe]
  • A collection of information that exists over a long period of time, often many years. [Ullman]
  • 长期存储在计算机内、有组织的、可共享的数据集合。[萨师煊,王珊]

Database Management System (DBMS ):

( Database ) + A set of programs used to access, update and manage the data in database.

Major properties of DBMS

  • Efficiency and scalability (可扩展性) in data access; Reduced application development time;
  • Data independence (physical data independence / logical data independence);
  • Data integrity (完整性) and security;
  • Concurrent access and robustness (recovery).

3. DBMS

evolution

  • File processing system (1950s-1960s)
  • Network and hierarchical DBMS (1960s-1970s)
    • 网状数据模型、层次数据模型 - 网状数据库、层次数据库 (结构复杂、使用很困难)
  • Relational database systems (RDBMS)
    • Relational model (1970, E.F. Codd)
    • Relational database system developed (late 1970s)
    • Relational database systems on the market (1980s)
    • Matured relational DBMS technology (1990s)

classification

  • Object-oriented database system (OODBMS)
  • Object-relational database systems (ORDBMS)
  • Application-oriented database systems
    • Spatial, temporal, multimedia, Web databases
  • Data Warehousing (数据仓库), Online Analytical Processing (联机分析处理), and Data Mining (数据挖掘) systems (for data analysis)

4. Levels of Data Abstraction

different levels

How to use DB - Different usage needs different level of abstraction. (e.g., student score management system)

  • Physical level: describes how a record is stored. Files
  • Logical level: describes data stored in database, and the relationships among the data on upper level.
  • View level: application programs hide details of data types. Views can also hide information (e.g., employee’s salary) for security purposes.

view of data

Schemas (模式) and Instances (实例)

  • Similar to types and variables in programming languages ( type ↔ schema, variable ↔ instance)
  • Schema - the structure of the database on different level
    • Analogous to type information of a variable in a program
    • Physical schema: database design of structure at the physical level
    • Logical schema: database design of structure at the logical level
    • Subschema: schema at view level
  • Instance - the actual content of the database at a particular point in time
    • Analogous to the value of a variable

模式结构图

5. Data Models

  • Data model is a collection of conceptual tools for describing:
    • data structure
    • data relationships
    • data semantics
    • data constraints
  • Different data models:
    • Entity-Relationship model
    • Relational model
    • Other models

Steps of Database Design

  1. Requirement analysis
    • What data, applications, and operations needed
  2. Conceptual database design
    • A high-level description of data, constraints using E - R model or a similar high level data model
  3. Logical database design:
    • Convert the conceptual design into a DB schema
  4. Schema refinement
    • Normalization of relations: Check relational schema for redundancies and related anomalies.
  5. Physical database design : Indexing, clustering and database tuning
  6. Create and initialize the database & Security design Load initial data, testing Identify different user groups and their roles

Entity Relationship Model (实体-联系模型)

The diagram is below: model

Let's show an example: example

Relational Model

pic

From the diagram we can understand the meaning of schema, attribute, column and tuple.

6. Database language

Database Language:

  • Data Definition Language (DDL, 数据定义语言)
  • Data Manipulation Language (DML, 数据操纵语言)
  • Data Control Language (DCL, 数据控制语言)

SQL

  • SQL = DDL + DML + DCL
  • SQL has been widely used
    1
    2
    3
    SELECT customer-name
    FROM customer
    WHERE customer-id = '192-83-7465'