-
Relational database structure
-
Relationships : a single data structure, real-world entities and various connections between entities
-
Two-dimensional table : From the user's perspective, the logical structure of the data in the relational model is a two-dimensional table
-
Domain : a set of values with the same data type
-
Relationship representation : each row represents a tuple, and each column corresponds to a field
-
Attribute : the name of each column
-
Code :
- Candidate code : The value of an attribute group in the relationship can uniquely identify a tuple, then the attribute is called a candidate code
- Full code : In the most extreme case, all attribute groups in the relationship are candidate codes for this relationship mode
- Master code : select a master code from multiple candidate codes
- Main attribute : The attribute of the candidate code is called the main attribute
-
nature
- Different columns can be the same domain
- The order of the columns does not matter
- Candidate codes for any two tuples cannot be the same
- The order of the rows does not matter
- Amount must take atomic value
-
Relationship model
- The description of the relationship is static
- R (A1, A2, A3, A4 ...), R is the relationship name, A1, A2, A3 ... is the attribute name
- The value of the relationship: the state or content of the relationship pattern at a certain moment
-
relational database
- Definition: For a given application, the collection of all relationships constitutes a relational database
- Type: description of relational database
- Value: A collection of relational patterns defined on these fields
-
Relational operation
- Query, select, project, connect, intersect, merge, difference
- Data update: insert, delete, modify
-
Relational algebra
- An abstract query language for relational databases, expressing queries with relational operations
-
-
Integrity of relationship
-
Integrity constraints
- Integrity constraints that the relational model must satisfy: entity integrity and referential integrity—two invariants
- Constraints to be followed in application areas
-
Entity integrity rules
- A basic table usually corresponds to a set of entities in the real world
- Real-world entities are distinguishable and have unique identification
- The main code is used as the unique identifier in the relationship model
- The main attribute (main code) cannot be null
-
Referential integrity
-
References between relationships: references to different attributes
-
Foreign code:
- F is an attribute in the relationship R, but not the main code, and F corresponds to the main code of the relationship S, then F is the outer code of R
-
Referential integrity rules
-
-
User-defined integrity
- Constraints for a specific relational database
-
End