I still remember the feeling of reading tianshu when I read database system principles for the first time, and the cloud was in the fog. Now I have read this book for the second time, and I suddenly felt something, "Oh, it turned out to be like this !" Now, let's get started. Write it down and take it as a note.
ER Model
The basic elements of the ER model are: entities, contacts, and attributes.
- Entity: a data object refers to an objective object that can be differentiated in an application. (Entities in the ER model often refer to entity sets)
Entity set: A set composed of the same class of entities.
The object is represented by a box, and the name of the object is indicated in the box.
- Link: the relationship between one or more entities.
The contact is represented in a diamond frame and linked to the relevant entity using a line segment.
- Attribute: a feature of an object is called an attribute.
The attribute is represented in an elliptical box, And the underlined attribute is the identifier.
Example: A potential design ERTU of Teaching Management
LINK model
Relational Model: represents the data model of the association between entities in the form of a two-dimensional table.
- In a relational model, a field is called an attribute, a field value is called a property value, and a record type is called a relational model.
- The link mode name is R. A record is called a tuple, and a set of tuples is called a link or an instance.
- Generally, uppercase letters A, B, C ,...... Represents a single attribute, and a lower-case letter represents the attribute value. The number of attributes in a link is called the "number of elements", and the number of tuples is called the "base ".
- It is also called a table, a row as a tuples, and a column as an attribute.
Instance 1: relational mode R
A B C D |
A1 b1 c1 d1 A2 b2 c2 d2 A3 b3 c3 d3 A4 b4 c4 d4 |
Example 2: relational mode R (S #, C #, CNAME, TNAME). Its Attributes indicate the student ID, course number, course name, and instructor name of the elective course respectively.
S # C # CNAME TNAME |
S2 C4 PASCAL WEN S4 C4 PASCAL WEN S6 C2 ADA LIU S3 C6 BASIC MA |