The difference between a relational database and a non-relational database (i)

Source: Internet
Author: User

Talk about the difference between relational database and non-relational database the first bomb

Take the two most popular databases now: MySQL and MongoDB (a product between relational and non-relational, where we use a non-relational database for comparison with MySQL)

To give an example of a practical understanding: the system for students to choose a course (simplify to cite two of the system: students, courses)

First of all, the model built in MySQL is

Student Table (Student):

S

Sid

Name

Gender

Age

Address

Email

College

Class

1

Tom

Woman

19

A

111

Foreign language

141

2

John doe

Man

20

B

222

Management

142

3

Wang er Leper

Man

21st

C

333

Software

143

Schedule (Class):

C

Cid

Name

Teacher

1

Comprehensive Japanese

Zhao

2

Tax

Wang

3

Law

Li

4

Soft work

Sun

The intermediate table SC with c corresponding to S

TD align= "left" valign= "top" width= "188" >1
scid sid cid
1 1
3 2 2
5 3 4
This is the case when writing this system in MongoDB: Sid:1,name: Zhang San, gender: Female, Age:19,address:a,email:111,college: foreign language, class:141,cid:1 sid:2,name: John Doe, Gender: Male, Age:20,address:b,email:222,college: administered, class:142,cid:2 sid:3,name: Wang er Leper, gender: male, AGE:21,ADDRESS:C, Email:333,college: Software, class:143,cid:4 cid:1,name: Comprehensive Japanese, teacher: Zhao Cid:2,name: Tax law, teacher: Wang Cid:3,name: commercial law, teacher: Lee Cid                                                            : 4,name: Soft work, teacher: Sun If the student number for 1 students also selected a class number for 4 of the class, the student number 2 and selected a course number 3 of the class in MySQL inside the SC table added two fields finally this table becomes: Sc
Scid Sid Cid
1 1 1
2 1 4
3 2 2
4 2 3
5 3 4
And MongoDB added two document Sid:1,name: Zhang San, gender: Female, Age:19,address:a,email:111,college: foreign language, Class:141,cid:4 sid:2,name: John Doe, Gender: Male, Age:20,address:b,email:222,college: administered, Class:142,cid:3 above is on the "table" level look at the following from the perspective of the query:

The difference between a relational database and a non-relational database (i)

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.