Database test sites

1. Select the database, and the projection is connected:

 And a projection is generally selected to query the database, table selected attribute values ​​specified in projection operation to form a new table from the selected table. Which meet the condition is selected from the table is selected to meet the conditions to form a new row in the table as a result of the operation.

 Coupled by merging into a plurality of tables (the view);

 Selection (Selection): Select yes barrage operation, a table in its operands. The operation according to the given conditions, to meet the conditions of the selected row from the table into a new calculation result as a table, mark selection operations is σF (R), where σ is the selected operator, subscript F is a conditional expression , R is the table is operated;

 Projection (Projection): unary projection is, the operation specified attribute value selected from the table to form a new table, referred to as: ΠA (R), where A is the attribute name (i.e., column names) table, R is a table name;

 Connection (the JOIN): the two rows of the table by pressing the given conditions splicing new table, the order of execution: NATURAL connection -> Select -> Projection

 

2. In the relational model, relational integrity mainly refers to the following three aspects:

(1), the integrity of entities: the so-called entity integrity refers to the relationship (the relationship is so-called table) of the master key is not null value; for example the primary key table students generally learn to take based code number

  (2), referential integrity: it refers to the outer code with reference to the relationship of each element is either empty (NULL), or equal to the reference relation of the main elements of a code; Today is such Sept. 2 is a school day, I first came to college freshmen reported in the table of students, some students may not have had time to assign a specific class, so these have not yet had time to placement of the students in the student table Dean can take the class attribute null value NULL (null values ​​represent "uncertain"), and which has divided the classes students have to take some of the attributes of the class table, such as class categories, namely students belong to which classes, such as taking "software engineering", "computer technology" and so on. Referring to the relationship between foreign key table is also referred to, it is also referred to as a reference relationship table's primary key

. (3), user-defined integrity: refers to the relationship between the value of each property as a limit (or called constraints) such as gender specific definition of property can only be taken "male" or "female", and later age. the range, can take the values ​​0-130, but can not be negated, because of their age can not be negative.

 

3. The purpose is to ensure the integrity of the control data in the database semantics are correct, and security control belong together data protection mechanisms provided by the DBMS. Integrity control include: integrity constraints, concurrency control, crash recovery.

 Integrity constraints: Integrity constraint is the core of the integrity of the control. To achieve DBMS provides organizations of all integrity constraints, to ensure the correctness and accuracy of the database update operations will not destroy any data semantics.

 Concurrency Control: Incorrect concurrency can lead to such problems dirty reads, phantom reads and non-repeatable read and so on. The purpose of concurrency control is to ensure that a user's work will not work on another user's impact unreasonable. In some cases, these measures ensure that when operating with users and other users, the results obtained and the results of operations alone she is the same. In other cases, this means that the user's work influenced by other users in a predetermined manner.

 Recovery: Recovery is the third integrity control. In the application, the database is often the most central part, once the database is damaged, it will bring great losses, so the database recovery more and more important. Use of the database process, due to power failure or other reasons, it may cause the database to some minor errors, such as particularly slow to retrieve some of the tables, query data can not meet the conditions and so on. The reason these cases are often somewhat corrupted database or index is not complete. Any data recovery methods are based on data backup.

4.DBS (database system) contains DB (database) and DBNS (database management system)

5. Independence logic refers to a logical structure of the user applications and databases are independent of each other, i.e., when the logical structure of the data changes, the user may change the program.

6. uncommitted read (Read Uncommitted): dirty reads are allowed, that is possible to read uncommitted transactions from modifying data in other sessions.

  Read Committed (Read Committed): can only read the data already submitted. Most Oracle and other database is the default level (not repeatable read)

  Repeatable Read (Repeated Read): Read repeatable. Within the same transaction query start time of the transaction are consistent, InnoDB the default level. In the SQL standard, the isolation level eliminates non-repeatable read, but there are phantom read

  Serial Read (Serializable): fully serialized read, each reading will need to obtain a shared table-level locking, read and write to each other will be blocked.

7. There are three types of locks:

   Shared (S) lock: a plurality of block transactions may be shared page; no transaction can modify the page; usually completed page is read, S lock is released immediately.

   Exclusive (X) lock: only allows a transaction to block this page; any other transaction must wait until the lock is released to X to access the page; X locks until the end of the transaction in order to be released.

   Update (U) locks: be applied to predetermined X-lock on this page, which allows other transactions to read, but not X then applied to the U-lock or a lock; when the page being read to be updated, the upgraded to lock X ; U lock to be released until the end of the transaction when.

 

8. external mode, mode, the mode concept

 External mode: also known as sub-mode or the user mode corresponding to the user level, is one or a few users see the database view, is related to the logical data indicates an application. Outside pattern reflects the user view of the database.

 Mode: Also known as conceptual model or logic model, comprehensive data for all users by the database designer, according to a global view of the logical structure of a unified structure, it is a general description of the logical structure and characteristics of all the data in the database, and is common to all users view (global view). It reflects the overall concept of the database system.

 The mode: also known as the storage mode, corresponding to the physical level, all internal data in the database represents a description or bottom layer, is a logical database describing the lowest level, and describes the physical structure of data storage on a storage medium, corresponding to the actual the database stored in the external storage medium. It is stored in the database view.

  We want to ensure that the database physical data independence, it has nothing to do with the external mode, simply modify the mapping between modes and within modes.

9. (1), Configuration Interface: Configuration Hibernate, according to its start Hibernate, SessionFactory create objects;

    (2), SessionFactory interfaces: initialize Hibernate, serves as a source of data storage agency, to create a session object, SessionFactory is thread-safe, meaning it's the same instance of the application can be shared by multiple threads, is the heavyweight secondary cache;

    (3), session interfaces: Responsible save, update, delete, and query object is loaded, is a non-thread-safe, avoid multiple threads share a session, lightweight, L1 cache.

    (4), Transaction Interface: management services. You can commit and rollback of the transaction;

   (5), Query and Criteria interfaces: a database query execution.

Guess you like

Origin www.cnblogs.com/hole/p/11311091.html