Yesterday began to look at the database, the first chapter is a general database of some terminology and relational model, the next few chapters are around these to carry out, want to leave a review of the outline, wrote this blog.
Data : A symbol record describing a thing. can be text, graphics, images, audio, video and so on, the data have a variety of forms, they can be digitized and stored in the computer.
Database management System ( DataBase Management System, DBMS)
As with the control system, the basic software of the computer is about how to organize and store the data scientifically and how to obtain and maintain the data efficiently.
functions: (1) data definition function (2) data organization storage and management (3) Data manipulation function (4 Database management and Operation management (5) database setup and Maintenance functions (6) Other functions
Database System ( DataBase System,dbs)
definition: Is by database, database management system (and application development tool), Application and database administrator ( Database Administrator,dba) consists of a system that stores, manages, processes and maintains data.
Entity : Things that exist and differ from each other.
Properties : An attribute that an entity has. For example, attribute combinations (20123, John Doe, Male,1996076, computer) represent the properties of a student.
Code : A property set that uniquely identifies an entity is called a code. For example, student numbers are the code of the students ' entities.
Solid Type : A collection of entity names and attribute names to abstract and characterize homogeneous entities, called entity types. For example, students (school number, name, date of birth, department, school) is a physical type.
entity set : A collection of the same type is called an entity set. For example, all students are an entity set.
Linkages between entity-type internal contact and entity type, the relationship between entities usually refers to the relationships between the attributes that make up the entity, and the linkages between entities usually refer to the linkages between different entities. The relationships between entities are one-to-many, and many-to-many types.
a way of expressing the conceptual model : Entity --contact method, which is a conceptual model of real society, also known as e-r model, through e-r diagrams .
The data model is usually composed of three parts, data structure, operation and integrality constraint condition of data. .
- Data structure: Describes the composition of the database and the relationship between the objects. Long according to the type of data structure to name the model, such as hierarchical structure, network structure, relational structure of the data model to be named as hierarchical model, network model and relational model. is a static description of the system.
- Data manipulation: A variety of objects in the database the (Type) entity (value) allows the collection of actions to be performed, including operations and related operational rules. The database mainly has the query and the update (including inserts, deletes and modifies) two kinds of operations, is the system dynamic characteristic description.
- Integrity constraints for data: is a set of integrity rules.
A common data model
The main logical data models in the A> database domain are
1 Hierarchy Model
definition ; represented by a tree (hierarchical) structure Entity the data model of types and relationships between entities is called a hierarchical model (hierarchical models). In a tree, each node represents a record type, a line or edge between nodes represents a relationship between record types, each record type can contain several fields, a record type describes an entity, a field describes an entity's properties, and each record type and its fields must be named. If you want to access a record-type record, you can look down the table from the root node and follow the hierarchical hierarchy.
In a hierarchical model, a child node of the same parent is called a sibling node, and a node with no child nodes is called a leaf node. Examples for example right: node R1 are root nodes, R3, R4, R5 are leaf nodes, R2 and R3 and R4 and R5 are sibling nodes respectively.
Disadvantages
The disadvantages of a hierarchical model include:
(1) Many links in the real world are non-hierarchical, such as many-to-many connections, a node with multiple parents, and so on. The hierarchical model indicates that this kind of contact method is very inflexible, can not directly represent more than two entity type between the complex relations and the entity type of many-to-many links. It can only be solved by introducing redundant data or constructing non-natural data organization such as creating virtual node, which is prone to inconsistency.
(2) There are too many restrictions on the insertion and deletion of data.
(3) querying a child's node must pass through the parent node, because the hierarchy model specifies the precedence of all subtrees of any node, which implies control over the access path to the database. There is only one connection between parent and child nodes in a tree, so there is only one self-root node that reaches its path to any node in the tree.
(4) The attribute of any record in a tree node can only be a simple data type that cannot be re-divided.
(5) Hierarchical commands tend to be programmed due to their tight structure.
2 Mesh Model
Definition: the network structure represents the model of the entity type and the connection between the physical bodies. As the name implies, one thing is connected to the other, which makes up a network diagram.
A mesh model is a data model that provides the flexibility to describe things and their relationships .
The connection between things in the real world is more non-hierarchical, it is not intuitive to use the hierarchical model, and the mesh overcomes this malady, which can clearly express this kind of non-hierarchical relationship.
a data structure model for representing entity types and relationships between entities using a graph structure is called Mesh Model ( Network Model).
The mesh model cancels the restriction that the hierarchy model cannot represent the non-number structure, two or more nodes can have more than one parent node, then a direction tree becomes a direction graph, which describes the mesh model.
A storage unit in a mesh model that records as data . A record contains several data items . the data items of a mesh database can be multi-valued and composite data. Each record has a unique internal identifier that uniquely identifies it , called a code (DATABASEKEY,DBK), which is automatically assigned by the DBMS when a record is stored in the database. DBK can be regarded as the logical address of a record, as an alias for record, or as a search for records. The Mesh database is a navigation (Navigation) database, and the user does not only explain what to do when manipulating the database, but also explains how to do it. For example, in a lookup statement, you need to specify not only the object to be found, but also the access path .
Advantages
The advantages of the mesh data model are as follows.
(1) to describe the real world more directly. can represent a variety of complex relationships between entities.
(2) has good performance, high access efficiency.
Disadvantages
The disadvantages of the mesh data model are as follows.
(1) complex structure, the data definition language (DDL), Data Manipulation language (DML) complex, users are not easy to use. And the larger the application environment, the more complex the structure of the database becomes, which is not conducive to the end-user mastery.
(2) Data independence is poor, because the relationship between entities is essentially represented by an access path, so the application accesses the data to specify the access path.
3 Relationship Model
A relational model is made up of a set of relationships. Each relationship is a standard two micro-table. The following is an example of a student login table that describes some of the terminology of the relational model.
School Number |
Name |
Gender |
Age |
Library card number |
Your department |
S3001 |
Zhang ming |
Man |
22 |
B20050101 |
Foreign language |
S3002 |
Li Jing |
Woman |
21st |
B20050102 |
Foreign language |
S4001 |
Li Zhao |
Woman |
21st |
B20050301 |
Management |
Relationship : is a relationship that corresponds to a table that is usually said.
Meta-group : A single row in the table is a tuple.
Properties : A column in a table is a property, and a name for each property is the property name. (The chart has six columns corresponding to six attributes (school number, name, gender, age, library card number, where the department)
Code : Also becomes the code key. A property group in a table can uniquely determine a unique tuple, in which the number can uniquely identify a student and become the code in this relationship.
domain: A field is a set of values that have the same data type as the gender of the domain is (male, female), the name of the domain is a collection of all the school department names.
Component : A property value in a tuple.
the basic principle of a relational model is the principle of information: All information is represented as a data value in a relationship. Therefore, the relationship variables are not related to each other at design time; instead, the designer uses the same domain in multiple relationship variables , and if one property relies on another property, the dependency is enforced by referential integrity .
interrelationships: A database can contain several tables, a table has several fields, each table has several records (tuples), and each record (tuple) has a value for each field Advantages
(1) Single data structure
In the relational model, the relation between entity and entity is represented by the relationship, and the relationship corresponds to a two-dimensional data table, and the data structure is simple and clear.
(2) Normalization of relations , based on rigorous theory
the basic norm of constitutive relation requires that each attribute in the relationship is not re-divided, and the relationship is based on the strict mathematical concept with solid theoretical basis .
(3) Simple concept, easy to operate
The biggest advantage of the relationship model is simple, easy to understand and master, a relationship is a two-dimensional table, the user can only use simple query language to operate the database.
Three-level schema structure of database system
1 mode : Also known as logical mode, is a description of the logical structure and characteristics of all the data in the database, and the public data view of all users. It is the middle layer of the database system model structure, which does not interfere with the physical storage details and hardware environment of the data, and is independent of the application development tools and advanced programming statements. The database schema is based on a data model, which unifies the needs of all users and organically integrates them into a logical whole.
2 external mode : The outer mode is a subset of the pattern. A database can have multiple external schemas. Because it is a view of the individual users, if different users in the application needs, the way to look at data, the need to treat data confidentiality, and other aspects of the differences, the model description is different.
3 Internal mode : Also known as storage mode, a database has only one internal mode. It is a description of the physical structure and storage of data, and is the way data is composed inside the database.
Some terminology of the database