Relational databases and databases

Source: Internet
Author: User

Relational databases and databases

1. Relational databases

Relational Database: a database built on a relational model (mathematical model.

Relational Model: A so-called relational model. The relational model includes three aspects:

Data: data storage issues. Two-dimensional tables (with rows and columns)

Operation Command set: All SQL statements

Integrity constraints: Data constraints (fields and fields) in the table, and constraints between the table and the table (Foreign keys)

2. Relational Database Design

Relational Database: from the analysis of data needs to be stored, if a type of data (entity) should be designed as a two-dimensional table; the table is composed of the header (field name: used to specify the data name) and data components (actually stored data units)

Tables: rows and columns

Header Field name 1 Field name 2
Data Unit Data 1 Data Line

Analysis based on actual cases: Analysis of a teaching system, the lecturer is responsible for teaching, teaching students, teaching students in the classroom

① Identify the entities in the system: the lecturer table, student table, and class table

② Identify the data information that should exist in the object

INSTRUCTOR: name, gender, age, salary ......

Student: name, gender, student ID, subject ......

Class performance: Class Name, classroom number ......

Relational Database: maintains the relationships between entities and entities.

Internal entity contact: Each student has a name, gender, and subject information.

Name Gender Student ID Subject Age
Chen Female 030310303 Chemical Engineering 22
Duhong Male 030320305 Chemical engineering principles  
Fu Wei   030330303 Physical Chemistry  

All fields in the second row are describing the student Chen Ming (internal contact). The second column can only contain gender (internal constraint)-Internal Contact of the entity.

One of the characteristics of relational databases: If a field corresponding to a table does not have a value (data), but the system still needs to allocate space: relational databases are a waste of space.

The relationship between entities: Each student must belong to a certain class, and each class must have multiple students (one to multiple)

All fields in the second row are describing the student Chen Ming (internal contact). The second column can only contain gender (internal constraint)-Internal Contact of the entity.

One of the characteristics of relational databases: If a field corresponding to a table does not have a value (data), but the system still needs to allocate space: relational databases are a waste of space.

The relationship between entities: Each student must belong to a certain class, and each class must have multiple students (one to multiple)

Name Gender Student ID Subject Age
Chen Female 030310303 Chemical Engineering 22
Duhong Male 030320305 Chemical engineering principles  
Fu Wei   030330303 Physical Chemistry  

Class table

Class Name Classroom no.
Chemical engineering principles B203
Physical Chemistry A305

Q: Can the two tables determine which student belongs to which class or which class has which students?

Solution: Add a class field to the student table to point to the class (a unique class information must be found)

Name Gender Student ID Subject Age Class Information
Chen Female 030310303 Chemical Engineering 22 Chemical engineering principles
Duhong Male 030320305 Chemical engineering principles   Physical Chemistry
Fu Wei   030330303 Physical Chemistry   Physical Chemistry

Association between student entities and class entities-relationships between entities

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.