Relationship, relationship model, relationship model blablabla...

Glossary

Data : Data is the basic data stored in the database, such as the student's student ID, student's class
database : warehouse
database management system for storing data : database software, such as MySQL, Oracle
database system : database + database management system + application + database Administrator (big guy)

Entity : an objective object, such as a student and a teacher.
Attributes : the characteristics of the entity, such as student ID, name, and department
code : a set of attributes that can uniquely identify the entity. For example, the student ID is the student's code, and a student ID uniquely identifies a student. The student number and course number are the code of the grade, because the student number and the course number uniquely identify the grade
entity type of a course : the description of the entity, such as the student (student number, name, department)
entity set : the set of entities
contact : The relationship between the entity sets. One student corresponds to one bedroom (one-to-one), one department corresponds to multiple students (one-to-many), and multiple teachers corresponds to multiple students (many-to-many)

Relation : A collection of several tuples. To put it bluntly, it refers to the database table
relational model : the description of the relation is called the relational model, and finally the
relational model will be described in detail : a collection of several relations, that is, a database
attribute (relation): relative to the previous meaning attributes, especially where a column in a database table
tuples : a database record
components : a tuple attribute value
fields : a set of values having the same set of data types, is the range of properties, such as The domain of the gender attribute is {male, female}, and the domain of the student's education attribute is {bachelor, master, doctor, academician}

Candidate code : can uniquely identify the attribute group of a tuple, each attribute in the attribute group is indispensable. [T_student] (student ID, name, college), the name may be repeated, so the student ID can uniquely identify a record, and the student ID is the candidate code of t_student. Assuming that the name will not be repeated, then there are two candidate codes: student ID and name. Another example is [t_grade] (student ID, course, grade), one of the students can have multiple grade records, so a combination of student ID and course ID is required to uniquely identify a database record, so student ID and course ID are one of t_student Candidate code.
Super code : As long as an attribute group can uniquely identify a tuple, then it is said that this attribute group is a super code [t_student] (student ID, name, college), the name may be repeated, so (student ID) is a super code at the same time It is also a candidate code, (student number, name) can uniquely identify a tuple, so it is also a super code, but not a candidate code, because it can be uniquely identified without the name.
Primary attribute : The attribute in the candidate code is called the primary attribute. [T_student] (student ID, name, college), the student ID is the primary attribute and
non-primary attribute : either the primary attribute or the non-primary attribute. [T_student] (student ID, name, college), name and college are the
full code of non-primary attributes : in extreme cases, all the attributes in the table below form the candidate codes of the table, which is called the full code
primary key/ primary key: primary key, one There may be multiple tables, and one is often selected as the primary key.
Foreign key/ foreign key: foreign key. Assuming that a certain attribute attr of table A is the primary code of another table B, and there is a certain connection between A and B, it is called attr Is the foreign code
reference table : the table where the foreign code is referenced: the
table referenced by the foreign key (foreign key references)
Data integrity : Data integrity refers to the correctness and compatibility of data (in accordance with logic), and is divided into entity integrity, referential integrity, and user-defined integrity.
Entity integrity : the master code is unique and not a null
reference Integrity : references to non-existent entities are not allowed. Insert a record into the reference table. The external code of this record must have
user-defined integrity in the referenced table : user-defined data constraints. For example, gender can only be represented by male and female, and the age of a person is between 0-120. Common user-defined integrity includes NOT NULL, UNIQUE, CHECK, etc.

Internal mode : The description of the physical storage structure and storage mode of the database is the storage mode of the database inside the database. Take MySQL as an example, every time a table is created, one or more files are generated on the file system. These files store data, table information, and index information. This is called the internal mode
mode: the abstraction of the internal mode, that is, the database
External mode : the abstraction of the mode, that is
, the external mode of the application directly used by the user -mode image : to ensure the logical independence of the data. When the mode is changed (adding a table, increasing the structure of the table), the outer mode unchanged
mode-inner mode mapping can be guaranteed : the physical independence of the data is guaranteed. When the internal mode changes (for example, MySQL switches the storage engine), the mode can be guaranteed to remain unchanged, so that the external mode will not change.

Relationship model

The relationship pattern is a description of the relationship (what attributes are there, and how are the dependencies between each attribute), and a specific value of the pattern is called an instance of the pattern. The pattern response is the structure of the data and its connection. It is a type and is relatively stable. An instance reflects the state of the relationship at a certain moment, a value, and a relative change.
Want to view the relationship model of t_student? DESC t_student
want to view the relationship instance of t_student? SELECT * FROM student
In addition, the relational model has an agreed mathematical representation, R (U, D, DOM, F), R refers to the relationship name, U refers to a group of attributes, D refers to the domain, DOM refers to the mapping of attributes to domains, and F is Refers to data dependence. For example, suppose a student table t_student has attributes of student ID, name, gender, and college. Its mathematical representation is shown in the figure.
Insert picture description here
This article is a reprinted article, reprinted in: relationship, relationship model, relationship model blablabla...

Guess you like

Origin blog.csdn.net/qq1350975694/article/details/107160941