Information about the database
The disadvantage of file management system: Writing an application inconvenient data redundancy unavoidable application dependencies do not support concurrent access to files data connections weak difficult to represent the advantages of a data database management system by User view: The collection of interrelated data is less Data redundancy program and data are independent of each other to ensure the safe and reliable data to maximize the correctness of data can be used concurrently and to ensure that the consistency database management system database is a collection of data, it in a certain form of organization on the storage medium. DBMS is the system software of managing database, it realizes various functions of database system, it is the core of database system. The DBA is responsible for the planning, design, coordination, maintenance, and management of the database. Application: Refers to the basic function of database-based application database management system data-defined data-security data-backup Database system architecture stand-alone architecture mainframe/terminal architecture Master-Slave architecture (c/s) Distributed architecture entity-Contact model Type E-r entity entities: objective things or abstract events that exist and can be distinguished from each other are called entities. In the E-r diagram, the entity is represented by a rectangle, and the entity name is written in the box property: The relationship between the data and the relation of the entity is the relation between the information and the entity of the semantic chain: the relation between the attributes of the constituent entities. In the case of an employee, there is a connection between the employee number and the department manager number in the entity: the relationship between the different entities. Examples of the types of linkages between students ' elective entity and the student's basic information entity: one-to-many (1:1) multiple-to-many (1:n)-to-multi-link (m:n) data three-factor structure: a class of data type, content, nature Related objects, such as domains, attributes, and relationships in a relational model, and objects that relate to data, which express data from the data organization layer and manipulate the structure data of the field: extract: Extracts the content of interest in the data collection. (SELECT) Data update: Changes the data in the database. Constraint for (INSERT, DELETE, UPDATE) data: is a set of integrity rules entity (ROW) Integrity entities Integrity field (column) integrity domain Integrity Reference Integrity referential Integrity easy data planning process first stage: Set data, get fields to collect necessary and complete data items Fields converted to data tables The second stage: classify the fields, place them in the table, and establish the association of the tables: the Relationship between table and table splits the data table and establishes the advantages of the association save space and reduce the input error side The third stage of data modification: Normalized database Database normalization analysis Rdmbs design paradigm Basic Concept design relational database, conform to different specifications, design a reasonable relational database, these different specifications are called different paradigms, various The higher the paradigm, the smaller the redundancy of the model database. There are currently six paradigms for relational databases: the first paradigm (1NF), the second paradigm (2NF), the third paradigm (3NF), the Badesco paradigm (BCNF), the fourth paradigm (4NF), and the fifth normal (5NF, also known as the perfect paradigm). The paradigm that satisfies the minimum requirements is the first paradigm (1NF). The second paradigm (2NF) is further satisfied on the basis of the first paradigm, and the rest of the paradigms are referred to by analogy. In general, the database only needs to meet the third normal form (3NF) Paradigm: 1NF: Each column is an indivisible basic data item, and there cannot be multiple values in the same column, that is, an attribute in an entity cannot have multiple values or cannot have duplicate properties. Except for the same type of field, which is no duplicate column 2NF: The second paradigm must first satisfy the first paradigm, requiring each row in the table to be divided by a unique region. Typically, a table is added to a column to store the unique identity PK for each instance. Non-PK fields need to have direct correlation with the entire PK 3NF: The second paradigm must be satisfied first in satisfying the third paradigm. The third paradigm requires that a database table does not contain non-primary key information already contained in other tables, non-PK SQL Concepts sql:structure query Language Structured Query Language SQL interpreter number According to the storage Protocol: Application layer protocol, C/S S:server, monitor the socket, receive and process the client application Request C:client Program Interface CLI GUI application Programming Interface Odbc:open Database Connectivity jdbc:java Data Base Connectivity constraints Constraint: Constraint, the data in the table to be subject to the restriction of the primary key: The combination of one or more fields, the data filled must be able to uniquely identify the bank in this table; must provide data, that is, not NULL, a table can only have one unique key: The combination of one or more fields, the data must be in this table uniquely identifies the bank; Allow null, a table can have more than one foreign key: the data that a field in one table can fill depends on the data checked by the primary key or unique key of another table: field values are indexed in a range copy the data in one or more fields in the table to save, and these need to be sorted in a particular order A storage index is a special data structure that defines the advantages of a field as a lookup condition when it is found: Improve query speed disadvantage: Take up extra space, affect insertion speed index name relational operations are required to create an index: select: Pick the line projection that matches the criteria: pick the desired field Connections: Associative data model data for inter-table fields Abstract: Physical layer: Determines the storage format of the data, that is, how the RDBMS organizes the file logic layer on disk: Describes what data is stored, and what relationships exist between the data. View layer: Describe some of the data in the DB Classification of relational models: a semi-structured relational model of object-based relational models: the naming rules for XML database objects must begin with a letter that can include numbers and three special characters (#,_, $) do not use the same schem as the reserved words of MySQL Object under a cannot have the same name database basic concept 1) data: Recorded information 2) Table: Record information is organized in the form of 3) database: A collection of tables, a warehouse for storing data about each other 4) database management system (DB management System,db MS): System software for effective database management. 5) database system, DBS: An interactive system consisting of hardware, operating system, database, DBMS, application software and database users. relational database 1) relational database is a database based on relational model, and the basic concept comes from relational model. Relationship isA two-dimensional table that satisfies the nature is that the row and column order in the table is not important. The relational model is based on the theory of relational algebra, and the data structure uses a simple two-dimensional table, which can be directly represented by the "entity-relation (E-R)" graph. The E-r diagram contains three elements of entities (data Objects), relationships, and attributes. 2) The relational database storage structure is a two-dimensional table that reflects the fact that things and their associated data are saved in tabular form. In each two-dimensional table, each row (row) is called a record that describes an object's information, and each column (column) is called a field that describes a property of the object. 3) Primary key, domain, and transaction for the relational database. The primary key (Primary key) is the field used to uniquely determine a record. Domain is the value range of the attribute, such as sex can only be a ' male ' and ' female ' two values. A transaction (transaction) is a multiple operation that is treated as a whole. 4) Common component databases for relational databases: Database table: Table row: Row column: Column index: Index view: View Users: User rights: Privilege stored procedure: procedure, procedure no return value stored function: Functions, Procedure has return value trigger: Trigger Event Scheduler: E Vent Scheduler, Mission plan 5) today's mainstream relational database 1 SQL Server (Microsoft): Window-oriented system, easy to use. 2 Oracle: For all major platforms, secure, sophisticated but complex to operate. 3 DB2 (IBM): For all major platforms, large, secure and complete 4 MySQL (Oracle Acquisition): Free, open source, small volume non-relational database 1) non-relational databases are called NoSQL (not only SQL), and stored data is not based on relational models , there is no need for a fixed table format. It serves as a complement to the relational database and is highly efficient and performant. 2) The advantages of non-relational database 1 "to meet the database high concurrency read and write requirements 2" to meet the massive data efficient storage and access 3 "to meet the database high scalability and high availabilityUse of sexual needs 3) non-relational database storage 1 "key-value way, the key to store, delete, change data 2" Columnstore (column-oriented), the relational data stored in the column Family 3 "document method, the database has some column data items Composition, each data item has a corresponding value 4 "graphical way, the entity is a vertex, the relationship is changed, the data is saved as a graph." 4) Non-relational database product 1 memcached: A cache system that stores data in key-value ways, caches data to relieve database pressure and speeds access, accelerates dynamic Web applications, and caches content in memory. 2 Redis is also a key-value store of data, and data is stored in memory, but data is periodically written to disk. Features: Support memory cache, support persistence, data type more, support cluster and distributed, support queue. Examples of applications are: Database front-end caching, session sharing, and the need to cache more data in addition to Key-value, when the cached data needs to be preserved for a long time. RDBMS DBMS---> RDBMS paradigm: First paradigm, second normal, third paradigm table: Row (Row), column (columns), relational operations: Select projection number Libraries: tables, indexes, views (virtual Tables), SQL, stored procedures, stored functions, triggers, event schedulers; constraints: PRIMARY KEY constraint: Unique, non-null; one table can only have one; Unique key constraint: Unique, can exist more than one; foreign KEY constraints : referential constraints; CHECK constraint: checked; three-tier model: Physical Layer--and SA logical layer--and DBA view Layer--coder implementation: Oracle, DB2, Sybase, Infomix, SQL Server, MySQL, mariadb, PostgreSQL, SQLite, dirty read, non-repeatable read, Phantom read dirty read: dirty read is when a transaction is accessing the data, and the data isModified, and this modification has not yet been committed to the database, another transaction accesses the data and then uses that data. Non-repeatable read: Refers to reading the same data multiple times within a transaction. When this transaction is not finished, another transaction accesses the same data. Then, between the two read data in the first transaction, the data that the first transaction two reads may be different because of the modification of the second transaction. This occurs when the data that is read two times within a transaction is not the same and is therefore called non-repeatable read. For example, an editor reads the same document two times, but between two reads, the author rewrites the document. When the editor reads the document for the second time, the document has changed. The original read is not repeatable. You can avoid this problem if the editor can read the document only after the author has finished writing it all. The key to non-repeatable reading is to modify: the same condition, the data you read, read it again and find the value is different. Phantom reads: A phenomenon that occurs when a transaction is not executed independently. For example, the first transaction modifies the data in a table, which involves all rows of data in the table. At the same time, the second transaction modifies the data in the table by inserting a new row of data into the table. Then the user who will be working on the first transaction in the future finds that there are no modified rows of data in the table, as if the illusion had occurred. For example, an editor changes the document submitted by the author, but when the production department merges its changes into the primary copy of the document, it finds that the author has added the unedited new material to the document. This problem can be avoided if no one is able to add new material to the document until the editor and production department have finished processing the original document. The focus of the Phantom reading is to add or remove the same conditions, the 1th and 2nd reads are different. The Isolation property supports a total of five transaction settings, as follows: Default using Database Settings Isolation level (default), the isolation level is determined by the DBA's default settings. Read_uncommitted dirty reads, non-repeatable reads, Phantom reads (lowest isolation level, high concurrency) read_committed can cause non-repeatable reads, Phantom reads (locks on rows being read) Repeatable_read Read (lock all rows Read) SERIALIZABLE ensure that all conditions do not occur (lock table)
About the database