当前位置:网站首页>Introduction to database system - Chapter 2 - relational database (2.1~2.3) (important knowledge points)

Introduction to database system - Chapter 2 - relational database (2.1~2.3) (important knowledge points)

2022-06-11 11:07:00 Filling in notes, checking for deficiencies, filling in gaps


Preface

take 【 Introduction to Database System ---- Chapter two – relational database (2.1~2.3)】 The important knowledge points in



1. Relationship

The relation is a finite subset of Cartesian product .
The relation is a two-dimensional table .
Cartesian product itself is meaningless in physical space , The relation is to extract a meaningful subset from the Cartesian product .

  • Related terms :
    • Objective ( degree ): There are several columns in the table for several degrees or items .
    • There are several behaviors and several relationships .
    • Each row of the table corresponds to a tuple .
    • Each column of the table corresponds to a field , Each column of the table corresponds to an attribute ,n Objective relationship n Attributes .
    • Candidate code : If an attribute in the relationship can uniquely identify a tuple , Call this attribute a candidate code .
    • Main code : If a relation has more than one candidate code , Select one of the main codes .
    • Main attribute : The attribute of the candidate code is the primary attribute .
    • Non primary property ( Or non code properties ): Attributes that do not contain any candidate codes are non primary attributes or non code attributes .
    • Full size : If all the attributes of a relational schema are candidates for this relational schema , Full code .
  • There are three types of relationships , Basic relationship ( It is also called basic table or base table )、 Query table 、 View table .
    • The base table is the actual table , Is the logical representation of the actual stored data .
    • The query table is the table corresponding to the query result .
    • A view table is a table derived from a base table or other view table , It's a virtual watch , Not the data that should actually be stored .

2. The nature of the basic relationship

  1. Columns are homogeneous , That is, the components in each column are the same type of data , From the same domain .
  2. Different columns can come from the same domain , Call each of these columns an attribute , Different attributes should be given different attribute names .( Property name uniqueness ).
  3. The order of the columns doesn't matter , That is, the order of columns can be exchanged arbitrarily .
  4. Two candidate codes of... Cannot take the same value .
  5. The order of the lines doesn't matter , That is, the order of lines can be exchanged arbitrarily .
  6. The component must be atomic , That is, each component must take an inseparable data item ( Cannot have table in table ).

The relationship model requires that the relationship must be normalized , That is, the relationship must meet certain normative conditions . The most basic of these normative conditions is , Each component of the relationship must be an indivisible data item . Normalized relationships are referred to as paradigms .


3. Relationship model

The description of a relationship is called a relational schema .

  • Formal representation of relational schema :R(U, D, DOM, F)
    • R Name the relationship
    • U A collection of attribute names that make up the relationship
    • D by U The domain from which the attribute in the
    • DOM A collection of images to the domain for the attribute ( The values in each row correspond to the values in the field )
    • F Is the dependency set of data between attributes
  • Relational patterns are usually abbreviated to R(U) or R(A1,A2,...) among Ai For the property name .
  • The relationship pattern is static 、 The stability of the , And relationships are dynamic 、 Changing over time .

4. Relationship operation

  • Characteristics of relationship operation : Set operation mode , That is, the objects and results of the operation are collections .
  • Common relational operations :
    • Inquire about ( The most important part of relationship operation ):
      Query operations can be divided into selection 、 Projection 、 Connect 、 except 、 and 、 Bad 、 hand over 、 Cartesian product , Selection 、 Projection 、 and 、 Bad 、 Cartesian product is 5 Basic operations , Other operations can be defined and exported with basic operations .
    • Data update operation :
      Insert 、 Delete 、 modify
  • Common relational operations : choice 、 Projection 、 Connect 、 except 、 and 、 hand over 、 Bad 、 The cartesian product .
  • Basic relationship operations (5 Kind of ): choice 、 Projection 、 and 、 Bad 、 The cartesian product .

5. Classification of relational data languages

  1. Relational algebra : Express query requirements by operations on relationships .
  2. Relationship calculus : Using predicates to express query requirements .
  3. Structured query language (SQL): Between relational algebra and relational calculus .

6. Outer code

set up F It's the basic relationship R One or a set of attributes of , But it's not the relationship R Code of ,Ks It's the basic relationship S The main code of . If F And Ks Corresponding , call F yes R The outer code of , said Basic relationship R For reference relations ( Relationship R Medium F Referring to the relationship S Medium Ks), Basic relationship S Is a referenced or target relationship .


7. The integrity of the relationship

  1. Entity integrity : Main code ( In relation mode, the master code is used as the unique identifier ) The primary attribute in cannot be null .
  2. Referential integrity : Outer code or null value , Or equal to the main code value of a tuple in the referenced relationship .
  3. User defined integrity : The constraints that the application domain should follow .

Entity integrity and referential integrity are the integrity constraints that relational models must meet , It's called the two invariants of a relation .

原网站

版权声明
本文为[Filling in notes, checking for deficiencies, filling in gaps]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111053040428.html