Three point learning knowledge database (a)

An outer pattern mode, the mode

1. Mode outer

External mode is also called sub-mode or the user mode, it is visible in the form of user-visible part of the data, that is, the user's view.
A database can have multiple external modes.

2. Mode

Mode , also known logic mode, the entire logical structure data, and invisible to the user.
A database is only one mode.

3. internal model

Within the pattern , also known as storage mode, the physical structure and storage databases.
Only a pattern within a database.
Here Insert Picture Description

II. The application server

The application server is through a variety of protocols to provide business logic to the client program.

  • Provide access to business logic for a client application use, and receives a user request from the Web browser, execute the corresponding database application according to the application field of business rules, presentation of data operation request as a database server access interface and;
  • Receiving access results data from the database server and the client by the results returned to the client.

III. Relationship Model

Some basic concepts in the relational model, such as the tuple attributes, range, healthy, candidate key, the primary key is not explained, in the relational model described hereinRelational schemawithrelationship

  • Relationship Model : defined lines in the two-dimensional table, which describes the relationship. Generally expressed as (attribute 1, attribute 2, ..., attribute n), such as the relational model can be expressed as following teachers' teachers (teachers number, name, sex, age, job title, where the Academy).
    Static description of the relationship of relational schema is static, stable.
Number of teachers Full name gender age job title Whereabouts School
001 Joe Smith male 30 lecturer Accounting School
002 John Doe Female 46 professor Information Institute
  • Relationship : a relationship corresponds to a two-dimensional table, two-dimensional table is the relationship name.
    Relationship is dynamic, with the user operation of the database and change.

IV. Database Design

Database design is the process according to the needs of users in a specific database management systems, structures and establishment of a database of database design. Database system needs to support the operating system.
Database design six stages are as follows:
1. Requirements Analysis
2. Conceptual Design
3. Logical Design
4. Physical Design
The design verification
6. Operation and Maintenance Design

V. index

Index is the value of a database table in one or more columns perform a configuration of ranking, fast access to specific information index database table. The user can not see the indexes, they can only be usedSpeed ​​up the search / query.
In the case of a user query the database information when data is particularly large and sometimes it will cause slow query speed, the index is to accelerate the time of the query.

  • Indexing syntax

CREATE INDEX index_name ON table_name (column_name)

Where index_name indicates the index name, index name definable, table_name expressed the need to establish the table name index, column_name expressed the need to establish a column name index.
Examples of indexing as follows

CREATE INDEX StudentIndex ON Student (LastName)

StudentIndex which represents an index name, Student table indicates the student needs to index, LastName represent the name needs to be indexed.

  • Another method of indexing is to create a unique index, a unique index means that two rows can not have the same index value.
    Create a unique syntax is as follows

CREATE UNIQUE INDEX index_name ON table_name (column_name)

This difference can be seen on a grammatical syntax is more than a UNIQUE, UNIQUE represents a unique meaning.

VI. Triggers, Check Constraints, Default Constraints

Why the flip-flop, Check Constraints and Default constraints put it together, because they are binding function.

1. Trigger

Trigger is to meet a specific conditionAutomatically triggerDedicated storage process performed for ensuring that the data in the table follows the rules and constraints of the determined database designer.
The syntax to create a trigger

CREATE TRIGGER trigger_name
trigger_time
trigger_event ON tbl_name
FOR EACH ROW
trigger_stmt

among them

  • trigger_name : indicates that the trigger name, user definable;
  • trigger_time : shows the trigger timing, the value is before or after;
  • trigger_event : indicates triggering event, the value for the insert, update or delete;
  • tbl_name : REPRESENTATION table triggers, namely the establishment of the flip-flop on which tables;
  • trigger_stmt : indicates that the trigger program body, may be an SQL statement or several statements and end with begain included.

The following example creates a trigger

// create a trigger, when student data table is updated to show the students all the data in the table.
the Trigger student_change the Create
ON the After Student INSERT, Update, the Delete
AS
the SELECT * from Student;

2.Check constraints

check constraint to limit the values in the column of the range, such as sex only as "male" or "female", the bank card password can only be six and so on.

  • The following example to create a check constraint

CREATE TABLE Persons
(
Id_P int NOT NULL CHECK (Id_P>0),
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)

"Id_P" Create column CHECK constraints case, when the "Persons" table is created. CHECK constraints predetermined "Id_P" column must contain only an integer greater than zero.

3.Default constraints

default constraint for inserting a default value to the column. If this column has no other value is specified, the default is the default value constraints. For example, "City" column no other value is specified in the "City column" Creating constrained to have a default "Guiyang", then it defaults to "Guiyang."

  • Following example creates default constraint

CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255) DEFAULT ‘Guiyang’
)

VII. Temporary table, Tempdb database

1. temporary table

Temporary table with similar entity table, except during use, temporary tables are stored in the system database tempdb. When we no longer use temporary tables, temporary tableAutomatically deleted.
Temporary table into a global temporary tables and local temporary tables.
As we usually see #Temp as local temporary tables presented here is that the user when creating the table to add the "#" prefix table.

  • The following example creates a temporary table

SELECT * INTO #Customers FROM Customers

On the same example creates a temporary table #customers customers, then it can query into a temporary table #customers

SELECT * FROM #Customers

  • Create a temporary table in the role of
    a temporary table in more complex nested queries can improve query efficiency.
    (Ps: not demonstrate here how to improve efficiency, the author is not particularly understand, anyway, remember that its role is to improve the efficiency of queries
    / manual funny)

2.Tempdb database

Tempdb system database is a global resource, available to all users connected to SQL Server or SQL database is used.
tempdb for reservations:

  • Temporary user objects explicitly created, for example: a global or local temporary tables and indexes in the previous section, and temporary storage process, a variable table, the table or a table function returns the value of the cursor.
  • Internal objects created by the database engine.
  • Version store, aggregate data page, which contains the necessary support using row versioning features rows of data.

VIII. Distributed database, parallel database

1. Distributed Database

Distributed Database unified database on a computer network is logically configured with physically discrete units connecting the plurality of databases thereof. Each database unit connected together is referred to as a node or site.
Basic Features:

  • Physical distribution of
  • Logical integrity
  • Autonomy Site

4 is a distributed database system abstraction layer structure modes, namely:

  • Global outer layer
  • Global conceptual level
  • Concept partial layer
  • Local inner layer

2. Parallel Database

Parallel database system is a new generation of high-performance database system, the database system is established on the basis of MPP and cluster parallel computing environment on.
aims:

  • high performance
  • High Availability
  • Scalability

IX. Data Mining

Data mining also translated as data mining, is based on the established corporate business goals, a large number of enterprise data exploration and analysis reveal the hidden, unknown or known to verify the regularity, and further advanced its model of effective methods .
Data mining goal is to find hidden, meaningful knowledge from the database.
Data mining techniques include:

  • Correlation Analysis
  • Sequence analysis
  • Classification analysis
  • Forecast Analysis
  • Cluster analysis
  • Time series analysis

Data mining process:

  1. Problem Definition
  2. Establish a data mining library
  3. analyze data
  4. Adjustment data
  5. Modeling
  6. Evaluation and interpretation

X. data pages and data lines

Data page is the basic unit of data storage in SQL sever. The basic page size is 8KB, namely 1MB in total 128. The beginning of each 96-byte header, a system for storing information about the page. Each data page can store 8060 bytes of data.
Rows no fixed size, the line can not span pages, but some pages where the line can be removed, so the actual line may be very large.

  • Examples and data page rows of data
    in SQL sever 2008, 8060 may be stored for each page of data bytes of data. Table T provided 10,000 rows, each row occupies 4031 bytes, the table data is stored approximately _____MB storage space. (Rounded to the nearest integer result Press)

Analysis: Because the storage space in two rows add up to the subject is greater than the data page, the page can store one line, because there is 1M pages 128, 128 also may store lines, 10,000 / 78.125 = 128, the result is 78.

(PS: the article command prompt cmd query IP address values are displayed, represent what up to now have 1100+ views, but also gain a lot of points praise and comments, and I'm really surprised, in good faith author to thank those who gave me thumbs up and comment on friends, let us forge ahead together, I have a lot to learn from you is. the share is the author not understand the problems encountered in the process of learning three database by querying data is then combined with their written opinions, I feel confused, it seems, need to learn is! If there are errors or bigwigs have a better view of the text of the places please point it out, stupid willing humbly neighborhoods ~)

Released two original articles · won praise 36 · views 1505

Guess you like

Origin blog.csdn.net/qq_44321509/article/details/103857207