Chapter One Introduction
1 Database related concepts
-
Data : Symbolic records describing things
-
Database : Long-term storage in the computer, organized, shareable data collection
With less redundancy, higher data independence and easy scalability, and can be shared by users
-
Database management system : a management software
-
Database system : consists of databases, database management systems, application systems, database administrators, and users
Database Administrator (DBA)
2 Database development
- Manual management stage : data is not independent, redundant, and not shared
- File system stage : poor independence, poor sharing, and high redundancy
- Database system stage : structured, good sharing, low redundancy, good independence
3 Elements of the data model
- Data structure : describe the static characteristics of the system
- Data manipulation : dynamic characteristics
- Data constraints : integrity rules
4 Conceptual model
- Substance : things that exist objectively and can be distinguished from each other
- Attribute : a certain characteristic of the entity
- Code : the attribute set that uniquely identifies the entity
- Domain : The value range of the attribute is called the domain of the attribute
- Entity type : Use a collection of entity names and their attribute names to abstractly describe similar entities
- Entity set : a collection of entities of the same type
- Contact : one to one, one to many, many to many
ER
Substance-rectangle
Attribute-ellipse
Contact-Diamond
5 Data model
-
Hierarchical model -tree structure
-
Mesh data model
-
Relational data model -tables and tables
Relational integrity constraints (entity integrity, referential integrity, user-defined integrity)
6 Three-level model structure of database system
-
Mode (logical mode) : the description of the logical structure and characteristics of all data in the database, which is a common data view for all users
A database has only one mode
-
External mode (submode/user mode) : It is the description of the logical structure and characteristics of the local data that the database user sees and uses, and is the data view of the database user
A database can have multiple external modes
-
Internal mode (storage mode) : is the description of the physical structure of the data and the storage structure
A database has only one internal schema
For each external mode, the database system has an external mode/mode image
Mode/intra mode image is unique
Chapter 2 Relational Database
1 Concept
- Candidate code : If the value of a certain attribute group in the relationship can uniquely identify a tuple, and its proper subset is not enough, then the attribute group is a candidate code
- Main code : Choose one of the candidate codes as the main code
- Primary attributes : the attributes of the candidate code become attributes
- Non-code attributes : attributes not included in any candidate codes
- Relationship mode : R(U,D,DOM,F)
- R: Relationship name
- U: The set of attribute names that make up the relationship
- D: The domain from which the attribute in U comes from
- DOM: a collection of attributes to domain mapping
- F: A collection of data dependencies between attributes
2 Relationship integrity
- Entity integrity : all main attributes cannot take null values, not just the main code attributes
- Referential integrity : foreign code correspondence
- User-defined integrity : constraints on a certain attribute
Chapter 5 Database Security
1 business
Start with BEGIN TRANSACTION and end with COMMIT or ROLLBACK
ACID
- Atomicity (atomicity): indivisible, the operations in a transaction are either done or not done
- Consistency: From one consistency state to another consistency state
- Isolation (isolation): the execution of one thing cannot be interfered by another transaction
- Durability: Once a thing is submitted, its changes to the database data should be permanent
2 Concurrent operation and data inconsistency
-
Lost changes
-
Not repeatable
-
Dirty read