Home  >  Article  >  Database  >  What is the relational data model

What is the relational data model

青灯夜游
青灯夜游Original
2018-12-29 13:48:0928198browse

The relational data model is a data model that models data in the form of relationships or tables. It is used to represent the storage and processing methods of data in relational databases. In relational databases, relationships (tables) are used form to store data.

What is the relational data model

There are three major elements in the relational data model, namely: relational data structure, relational integrity constraints and relational operations. Let’s take a brief look at it below. [Related video tutorial recommendations: MySQL Video Tutorial]

Relational data structure:

The relational model represents the database as A collection of relationships (the logical structure of data in the relational model is a two-dimensional table). Let's take a look at some of the main structural concepts:

1. Table

In the relational data model, relationships are saved in the form of tables. It stores relationships between entities, with rows and columns, where rows represent records and columns represent the set of values ​​for a specific attribute. Example:

What is the relational data model

2. Tuple A row of the

table, a single record containing this relationship is called a tuple. Use "cardinality" to represent the number of tuples. For example: the cardinality of the student relationship defined above is 4 (there are 4 records).

3. Attributes

define the attributes of the relationship, for example: name and age are attributes of students. The total number of attributes in a relationship is called the "degree" of the relationship. For example: the degree of the student relationship defined above is 4

What is the relational data model

4. Relationship model

Relationship schema describes the relationship name (table name), attributes and their names. If a schema has multiple relationships, it is called a relational schema.

5. Relational instance

A set of finite element groups in a relational database system represents a relational instance. There are no duplicate tuples for relation instances.

6. Key key

Each row has one or more attributes, called relationship keys, which can uniquely identify the rows in the relationship (table).

7. Attribute Domain

Each attribute has some predefined value ranges, called attribute domains.

Integrity constraints of relationships

Every relationship must have some conditions to make it a valid relationship; and these conditions are called relationships Integrity constraints, there are three main integrity constraints, let's take a look below:

1. Key constraints

The relationship must have at least one minimum subdivision of the attribute A set that uniquely identifies a tuple. This minimal subset of attributes is called the key of the relationship. If there are multiple such minimal subsets, these subsets are called candidate keys.

Key restrictions

1), In the relationship with the key attribute, no two tuples can have the same key attribute value.

2), key attributes cannot have NULL values.

Note: Key constraints are also called entity constraints.

2. Domain constraints

Attributes have specific values ​​in actual scenarios. For example, age can only be positive integers. An attempt has been made to adopt the same constraints on the properties of the relationship. Each attribute must have a specific value range. For example, the age cannot be less than zero, and the phone number cannot contain numbers other than 0-9.

3. Referential integrity constraints

Referential integrity constraints indicate that if a relationship refers to a key attribute of a different or the same relationship, the key element must exist. It works with the concept of foreign keys. Foreign keys are key attributes of a relationship that can be referenced in other relationships.

Relationship operations:

Relationship operations mainly include: query, insert, delete, update and other operations.

The above is the entire content of this article, I hope it will be helpful to everyone's study.

The above is the detailed content of What is the relational data model. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn