System architecture: database

Database Design

Insert image description here

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

Insert image description here

  • 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.

Insert image description here

  • 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

Insert image description here
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.
Insert image description hereFirst 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


  1. Insert image description hereWhen 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) .
  2. transitive functional dependencyInsert image description here

Armstrong's axioms

Insert image description here

paradigm

Insert image description here

lossless decomposition

Insert image description hereJudgment based on the table method:
Please add image description
Insert image description herefirst 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
Please add image descriptionname 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:
Please add image descriptionThere is a row with all √, and the restoration is successful.

Guess you like

Origin blog.csdn.net/weixin_43249758/article/details/132434033