Detailed explanation of relational databases

table of Contents

1, understanding of relational database

1.1.1 What is a relational database

1.1.2 entity-relationship model

1.1.3 relational database management system RDBMS

1.1.4 use SQL database management language


1, understanding of relational database

In short database is a collection of data, which is developed by the file system to store data up, concurrency database system to solve the problem of people database read and write, and it provides a mechanism for the transaction, making the storage and management database data more secure and reliable. Database system only allows the user layer data processing logic, and other such tables and views. It allows users to use a simple and easy way to manage the operation of the data.

1.1.1 What is a relational database

Technical data After decades of development, has experienced labor management, file system to the current database management, provides more advanced and more efficient data management. Database system management data has the following characteristics:

      (1) using the data model indicates a copy of the database structure, the user can use the entity-relationship model to model the data, the data itself may be expressed not only the relationship between the data can also be described, which causes the data stored in the database easier to understand And maintenance.

(2) the data system logical structure and physical structure of data separation, the user can simply use the logical structure of the database operation, without regard to physical storage structure simplifies the complexity of database operations. Generally, a database system can be divided into three as shown in Figure 1.1.

(3) database system provides control data, he provided a multi-user concurrency mechanisms to prevent data from being illegally database changes. The database system will provide data backup and restore functions, can avoid a catastrophic data loss caused by time. Data provides data integrity features, and provides the necessary security mechanisms.

Relational database system in the last 30 years, the mainstream model of database systems, he uses the relationship between the data model to store and manage databases. Relational database model and the establishment of the 1970s, the United States EFCodd published a paper once called "large shared data in a relational database model", he defines a relationship model based on mathematical geometric theory, a relational database is consistent with database relational model.

● Note: "large shared data in a relational model database" already has a simplified Chinese version, interested users can learn more about this side of the paper by the hash engine.

In the real world summary, large amounts of data are have some relevance, relational database systems is the relationship more data of the data structure of the organization and storage. Definition of a relational database in a nutshell is: use relational or two-dimensional tables to store information. It is a two-dimensional table rows (tuples may also be referred to) and columns (see also be referred to as attributes) composed of entities commonly referred to as a table or a relational database. Each row in the table have the same column set, and therefore may be referred to as a relational data stored in relational database tables.

For example, the personnel department for data storage, you can create an employee table and a department table, since each employee personnel information table belong to the department, therefore references between relational database table will store employees and departments relationship. When not using the relational database system, departments may recognize a person table is created using Excel, a schematic configuration shown in Figure 1.2.

Personnel department also created a department table, the department table contains the name of the department, department number and other location information department of the department, staff table should be consistent with the department name the department table, or database database will be chaos, shown in Figure 1.3.

Also stores the relationships between the tables stored in the relational database of basic data outside. Relational data will maintain the integrity of these relationships, again providing more storage structure words.

1.1.2 entity-relationship model

The main database used to store real-world data, relational databases by using a table box relations to store data, you can save the data set in the real world. Entity-relationship model of the real world abstract, obtain the relationship between entity types and entities to describe the composition of the structure of real world data. After building the entity relationship, entity relationship generally to FIG clearly express the relationship between the entity mechanism. Entity Relationship Diagram (Entity Relationship Diagram) refers to the provision of balance-sheet entities, attributes, and a graphical representation of the relationship, the conceptual model used to describe the real world, referred to as ER diagrams.

Entity-relationship model has three core elements, during the analysis and design of the database, we need to seriously understand the specific meaning of these elements and in the form of a summary of the ER diagram, shown separately below.

● entity (Entity): having the same features and attributes of the display world transaction abstract, are collectively shown in FIG ER rectangle, rectangle indicate the name of the entity. Such as employee Joe Smith, Zhao seven employees are entities.

● attribute (Attribute): refers to an entity having a characteristic, an entity may comprise several entities. FIG aggregate properties in the ER is represented by an ellipse, and using lines to connect with the corresponding entity. For example, employees with property job number, entry date.

● relationship (Relationship): refers to the way more like links between entities, typically one to one relation (1: 1), many relationship (1: N), many relationships (M: N).

To recognize employees and personnel information management systems leave an example, by using the entity relationship model, the receipt ER entity relationship diagram shown in Figure 1.4.

Can be found from FIG. 1.4, a single person, and leave these two entities rectangles, using the attributes of the entity represented by an ellipse, the relationship between the entity and the entity represented separately. Personnel leave alone entity ranking entity and relationship Yong-to-many, and therefore the use of N 1 indicated near separately.

In general, the database database designer needs analysis, to communicate with users of the database, the database designer may require receipt of many different types of plans to form a relational database storage structure, the receipt ER relationship in the logical design phase FIG., may be used Visio, PowerDesigner ERWin Data Modeler or other software.

1.1.3 relational database management system RDBMS

Database management system is a computer software program to create a relational database model, and its English name is Relational Database Management System, referred to as RDBMS. A set of database management system is a database management program in the operating system and user (or based database applications) between, it provides a unified management and control function of data in the database, for the final analysis, database in the form of data files stored in the operating system, database management system provides advanced database and tissue formation, he provides the functionality of unified management and control of data in the database, the database management system and the user diagram of Figure 1.5 Fig.

Database management system is responsible for the full range of database management, he includes several functions shown in Figure 1.6.

As shown in FIG 1.6, a database management system typically provides several features shown below.

●定义数据库结构:DBMS提供数据定义语言来定义(DDL)数据库结构,用来搭建数据库框架,并被保存在数据字典中。

●存取数据库内容:DBMS提供数据操作语言(DML),实现对数据库数据的基本存取操作——检索、插入、修改和删除。

●数据库的运行管理:DBMS提供数据控制功能,即数据的安全性、完整性和并发控制等对数据库运行进行有效的控制和管理,以确保数据正确有效。

●数据库的建立和维护:包括数据库出事数据的装入,数据的转储、恢复、重组织,系统性能监视、分析等功能。

●数据库的传输:DBMS提供处理数据的传输,实现用户程序与DBMS之间的通信,通常与操作系统协调完成。

有了关系型数据库管理系统,开发人员就可以在数据库中创建数据库、创建表、存取数据库内容、对数据库进行备份和管理,只需要理解常用的系统相关的操作,而不用去研究关系型数据库系统内部深奥难懂的数学方方面的理论知识。

目前比较常见的DBMS有Oracle、SQL Server、Mysql、DB2等,它们都使用关系型数据库模型作为基础构建的软件,它们建立在关系数据模型的基础之上,通过一系列相关的表和其他数据库,对象把现实世界中存在的事务及事务之间的联系用数据库对象,比如表、视图、索引、关系加以存储,使之为数据库的用户提供规范化的信息。

1.1.4  使用SQL语言管理数据库

为了便于管理关系型数据库,数据库管理系统使用一种称为SQL的声明性语言。SQL的全称是结构化查询语言(Structured Query Language),是一种对关系数据库中的数据进行定义和操作的句法。他独立于数据库管理系统,并且以经被国际标准化组织指定为一种操作数据库的标准语言。SQL语言可以操作和管理数据库,各种数据库管理厂商使用SQL标准来定制自己的数据库管理方式,因此它对于所有的数据库管理系统来说是通用的。

●注意:由于不同的数据库厂商对SQL语言的支持与标准仍然存在着细微的不同,因此在使用时必须要参加各个数据库厂商提供的SQL操作文档。

SQL语言是一种高级的非过程化编程语言。SQL语言允许用户不了解数据库的底层结构和具体的操作方式,只需要在一个标准化的、较高层次的数据结构上进行工作,这就大大简化了数据库的操作方式,同时因为不与数据库、硬件等紧密耦合,因此也使得基于数据库的应用系统具有很好的可移值性。其操作示意如图1.7 所示。

由图中可以看到,任何客户端通过SQL语言来与数据库管理系统进行通信,通过向服务器端发送SQL语句,数据库管理系统将这些SQL语句转换为实际的对数据库数据进行操作的指令来对数据库进行管理,这简化了数据库管理系统的复杂程度,提高了用户对数据库的使用效率。

SQL语言主要又分为如下6大类。

(1)数据查询语言(DQL) :也称为“数据检索语句”,用于从表中获得数据,确定数据怎样在应用程序给出。关键字SELECT是DQL ( 也是所有SQL)用得最多的语句,其他DQL常用的关键字有WHERE、ORDER BY、GROUP BY和HAVING.这些DQL关键字常与其他类型的SQL语句一起使用。

(2)数据操作语言(DML) :分别用于添加、修改和删除表中的行。也称为动作查询语言。

(3)事务处理语言(TPL) :能确保被DML语句影响的表的所有行及时得以更新。TPL语句包括BEGIN TRANSACTION、COMMIT和ROLLBACK.

(4)数据控制语言(DCL) :通过GRANT或REVOKE获得许可,确定单个用户和用户组对数据库对象的访问。某些RDBMS可用GRANT或REVOKE控制对表单各列的访问。

(5)数据定义语言(DDL):在数据库中创建新表或删除表(CREAT TABLE或DROP(5)数据定义语言(DDL):在数据库中创建新表或删除表(CREAT TABLE或DROP也是动作查询的一部分。

(6)指针控制语言(CCL) :用于对一个或多个表的单独行进行操作,比如DECLARECURSOR、FETCH INTO和UPDATE WHERE CURRENT等语句。

You can see these SQL statements basically covers all aspects of database operation, basically most of the time learning database operations are managed using SQL statements, so for a qualified DBA, the SQL language proficiency is very necessary.

Guess you like

Origin www.cnblogs.com/XXXHui/p/12050368.html