Database Principles and Applications B Brief Summary Edition Review Notes-Chapters 2 and 3

Chapter 2 Relational Database

1. Relations and related concepts:
Domain : A set of values ​​with the same data type, such as {male, female} (the definition of a domain is a frequent visitor to multiple-choice questions)
The cardinality of the domain: the number of different values ​​allowed in a domain
Cartesian product: D1XD2X……XDn
Example: D1={张,王,李} D2={cs,math} D3={T,S}
There are 3 2 2=12 combinations of
candidate codes : the value of a certain attribute group Can uniquely identify a tuple, but its subset cannot , then the attribute group is called the candidate code
main code : one of the candidate codes
Full code: candidate code = all attributes
Main attribute: the attribute of the candidate code is
not the main attribute/non-code Attribute: Not a candidate code

There are three types of relationships: basic relationships ( basic tables or base tables- actual tables ), query tables (tables corresponding to query results), and view tables ( virtual tables derived from basic tables or other view tables )

2. Relationship mode: description of the relationship R (U, D, DOM, F)
R: the name
of the relationship U: the set of attribute names that make up the relationship
D: the domain from which the attributes in U come from
DOM: the set of mapping attributes to the domain
F: Data dependency collection between attributes

3. The relationship model is static and stable , while the relationship is dynamic and constantly changing over time

4. Relational database: The type of relational database is also called the relational data model, which is a description of the relational database.
The value of a relational database is a collection of relations corresponding to these relational patterns at a certain moment, which is generally called a relational database.

5. The storage structure of the relational model: table storage

6. Relational operations: query (selection, projection,
union , difference, Cartesian product, connection, division, intersection), insert, delete, modify the objects and results of operations are all sets

7. Relationship integrity:
(1) Entity integrity : If attribute A is the primary attribute of basic relationship R, then A cannot take a null value .

Note: The concept of outer code : Let F be one or a group of attributes of basic relation R, but not the code of relation R, and Ks is the main code of basic relation S. If F corresponds to Ks, then F is the outer code of R, and the basic relationship R is called the reference relationship, and the basic relationship S is the referenced relationship.
R(Kr,F,…)->S(Ks,…)

(2) Referential integrity: If the attribute F is the outer code of R, which corresponds to the main code Ks of the basic relationship S, then the value of each tuple in R on F must be: either a null value; or equal to The main code value of a tuple in S

(3) User-defined completeness: for example age[0~65]

Chapter 3 Structured Query Language SQL

Functions: data query, data manipulation, data definition, data control

1. SQL features:
(1) Comprehensive and unified
integration of data query, data manipulation, data definition, and data control functions, which can independently complete all activities in the DB life cycle
(2) Highly non-procedural
What to do (√) How Do understand the storage path
(3) Set-oriented operation mode
(4) Provide multiple usage methods with the same grammatical structure
(5) Simple language, easy to learn and use

2. SQL verb
data query: SELECT
data definition: CREATE, DROP, ALTER
data manipulation: INSERT, UPDATE, DELETE
data control: GRANT, REVOKE

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

Lord's words are so ugly, there is no way, just go.

It is not easy for Pipilei to organize, please praise and attention, thank you!

Guess you like

Origin blog.csdn.net/qq_43704702/article/details/108432490