Article directory
Database Design
step | output | illustrate |
---|---|---|
1. Conduct demand analysis based on data requirements and processing requirements | Data flow diagram, data dictionary, requirements specification, etc. | Analyze data flow, detailed meaning of data, etc., and analyze specific needs |
2. Abstract the real world and design conceptual structures | ER model | Used to describe entities and the relationships between entities |
3. Add conversion rules, standardization theory and DBMS characteristics to design the logical structure | relationship model | Design database table structure |
4. Add hardware features, OS features, etc. to physical design | - | How design data is physically stored |
relational algebra
- Cartesian product: No isomorphism is required. The column of the result is the sum of the two (3+3=6), and the row of the result is the product of the two (3*3=9).
- Projection: Filter specific columns in the vertical direction, and the table structure changes.
- Selection: Filter specific rows horizontally without changing the table structure.
- Natural connection: isomorphism is not required. The result column is the sum of the two to eliminate duplication. The result row requires that all attribute columns with the same name have equal values at the same time. Equation 1 in the figure is the equivalent expression using Cartesian product->selection->projection. Mode. If the same operation is implemented, the performance of natural connection is slightly better than Cartesian product.
normative theory
Find candidate keys
The relational pattern R contains two tuples, the attribute set U and the functional dependency set F, denoted as R(U, F). The attribute set is represented as a node and the dependency is represented as an arrow. R can be converted into a directed graph.
First find two types of nodes:
- Only appears on the left, never on the right. Must be included in the candidate key.
- Only appears on the right side, never on the left. Must not be included in candidate keys.
In the figure, C only appears on the right side, so it must not be included in the candidate keys. If there is only A, it can be traversed to BC and completed. If there is only B, it can be traversed to AC and completed. Therefore, the candidate keys are A and B (note not AB).
Special functional dependencies
When some functions depend on candidate keys and there are multiple attribute sets (the candidate key in the figure is AB), there is an attribute set that only depends on part of the candidate keys (C only depends on A) .- transitive functional dependency
Armstrong's axioms
paradigm
lossless decomposition
Judgment based on the table method:
first find the attribute column with the same name (student number in the student relationship and student number in the grade relationship), then you can restore the name to the grade relationship by relying on (student number -> name), and the table becomes: Continue to look at the next one with the same
name In the attribute column (the name of the student relationship and the name of the grade relationship), there is no dependency available. Continue to find the next one (the course number of the grade relationship and the course number of the course relationship). You can change the course name through the dependency (course number -> course name). After restoring to the grade relationship, the table changes:
There is a row with all √, and the restoration is successful.