Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is a database relational connection

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is a database relational connection". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is a database relational connection"?

Connection classification

Connections between relationships are divided into inner connections (inner join) and external connections (outer join).

External connections can be divided into left outer join,right outer join and full outer join.

Internal connection calculation method:

If no condition is added, it will produce Cartesian product.

If there are join conditions, operate according to the rules of the next section "join conditions", and the tuples that meet the conditions are put into the result relationship.

Left outer join calculation process:

1) calculate the inner join under the same connection condition, and put the qualified tuples into the result relationship.

2) if any tuple in the left relation does not meet the condition, put it in the result relationship and supplement the rest with NULL

Right outer join calculation process:

1) calculate the inner join under the same connection condition, and put the qualified tuples into the result relationship.

2) if any tuple in the right relation does not meet the condition, put it in the result relationship and supplement the rest with NULL

Full outer join

1) calculate the inner join under the same connection condition, and put the qualified tuples into the result relationship.

2) if any tuple in the left-right relationship does not meet the condition, put it into the result relationship, and make up the rest with NULL

As is used to modify the relationship name and attribute name of the result relationship after the connection.

Connection condition

The connection between relationships can be conditional, the outer connection must be conditioned, and the inner connection without conditions will produce Cartesian product.

What are the connection conditions?

Natural--

1) the values of all attributes with the same name in the two relationships (left relationship and friend relationship) should be equal.

2) natural always appears before the join statement

3) in the result relationship of natural, attributes with the same name will only appear once.

4) in the result relation of natural, the order of attributes is always in accordance with the principle of left relation first.

5) in MySQL, natural join cannot use on to specify other query criteria

On--

1) on is used after the join statement

2) relation 1 is adopted after on. Attribute a = relation 2. Predicate syntax for attribute b

Using--

1) similar to natural, except that the attribute name is explicitly specified

2) if using also specifies all attributes with the same name, it is the same as natural

MySQL

In MySQL, natural join and left outer join cannot be used at the same time. You can first make the natural join statement into a view, and then use left outer join

Join defaults to inner join

At this point, I believe you have a deeper understanding of "what is a database relational connection". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report