The basic idea of the database (b)

First, the basic concepts of database

1, a relational database

(1) Relationship between operation

  Object relations operations and results of operations are set to become a way of a set. Database operation rather than a relational data model is a record of the way.

  Relational data model is the most important relationship query operation, is divided into: selection (SELECT), a projection (Project), the connection (jion), except (Divide), and (Union), the difference (the except), cross (intersection) Cartesian product and so on. Wherein selecting the projection, and the difference, Cartesian product of five basic operations.

(2) relational database language

  In practical relational database systems, to achieve selection, projection, and, poor operation, the user is provided a relational algebra and relational between checking language SQL (Strutured Query Language, Structured Query Language). SQL language is a structured query language for relational databases, many relational database management system to support the SQL language, such as SQL Server, Access, Oracle, DB2, MySQL and so on.

  SQL language functions include data query, data manipulation, data definition and data control section four. SQL language is simple, convenient and practical, to fulfill its core function only six verbs --SELECT, CREATE, INSERT, UPDATE, DELETE, and GRANT (REVOKE). As a standard language for relational database Although used by many commercial database management system products, but a different database management systems are in the process of practice for SQL specification did something adaptation and expansion. So, in fact between different database management systems SQL language can not be fully interoperable. ORACLE databases such as Oracle's SQL language is used in the Procedural Language / SQL (referred to as PL / SQL), and Microsoft's SQL Server database system is supported by Transact-SQL (referred to as T-SQL).

Integrity (3) the relationship

  Integrity rules relational database model is some sort of constraints on relationships. There are three types relational model Integrity Constraints: entity integrity, referential integrity integrity, user-defined. Among entity integrity and referential integrity is the relational model integrity constraints that must be met. Two is called invariance relationship. On their own initiative should be supported by a relational system.

  • Entity integrity (Entity Integrity): If the property (refer to a set of attributes or a) A basic relationship is the primary attribute of R, then A is not null value. The so-called null value is "do not know" value or "does not exist".
    Entities in accordance with the rules of integrity, the basic relationship of the master key can not take control.

    Assume that the primary code consisting of a number of attributes, the attributes are not all of these primary null value.
    For Entity integrity rule description:
    1) entity integrity rules for the purposes of basic relations. A basic table usually corresponds to a real world entity set.

    Student relationship as corresponding to a set of students.
    2) real-world entities are distinguishable. That they have some unique identification. For example, each student is an individual, is not the same.
    3) the relationship between the master model to a unique identification code.
    4) primary key attributes, i.e., the main properties can not take a null value. Assume that the primary attribute null value. It shows the existence of a non-entity identifier, that is indistinguishable physical presence, which is 2) contradicts, so this rule is called entity integrity.

  • Referential integrity (Refernetial Integrity): In real life, there is often a link between the entities, the link between physical machines entity in database model are described by the relationship, so that there is a reference to the relationship between the relationship. In a relational database system, expressed by introducing the concept of foreign key references to each other entities.

  1) provided R F is a fundamental relationship or a set of attributes, but not in a relationship of R.

  K S is the basic relationship of the primary key. Suppose F and K corresponding phase, called the F R is the outer code (foreign key).

  Adding that the basic relation R relationship as a reference.

  S is the basic relationship is the reference relationship. The outer code is not necessarily the same name and the corresponding key.
  2) If the attribute (or attribute group) F R is the basic relationship of the outer code. It is the basic relationship with the master key K corresponding S phase (basic relations R and S are not necessarily different relationship). R for each of the tuple over F value must be: ◀ or null value (F value of each attribute are null) ◀ or equal to the primary key value of a tuple in S.

  • User-defined integrity (User-defined Integrity): entity integrity and referential integrity is any relational database system must support. In addition, different relational database systems, depending on their application environments often require some special constraints, user-defined integrity constraint is for a specific relational database. It reflects the semantics of a data requirements must be met particular application involved.

  For example, in the 'students' table, the user specifies a total of 60 minutes before credits to pass.

 

Guess you like

Origin www.cnblogs.com/xhbJava/p/11074775.html