15 junction Table

Source: Internet
Author: User

Relational tables are designed to ensure that information is broken into multiple tables, a single table of data, and tables that are interconnected by some common values
Primary key: Uniquely identifies a foreign key: a foreign key is a column in a table that contains the primary key value of another table.
Advantages: More efficient storage, more convenient handling, greater scalability
Note: The junction is not a physical entity, it does not exist in the actual database table, is established by MySQL as needed, and exists in the execution of the check query.

SELECT Vend_name,prod_name,prod_price from vendors,products 
WHERE vendors.vend_id=products.vend_id ORDER by Vend_ Name,prod_name

The importance of the WHERE clause: when you join two tables, you are actually pairing each row in the first table with each row in the second table with a WHERE clause as the filter condition, and he only covers
The rows for those matching conditions, with no WHERE clause, each row in the first table is paired with each line in the second table, regardless of whether their logic can fit together.

Cartesian product: The result of a table relationship without a join condition returns a Cartesian product, and the number of rows retrieved will be the number of rows in the first table multiplied by the rows in the second table.

You should ensure that there is a WHERE clause in the join, otherwise you will return a large amount of data

Internal coupling: Also known as equivalent junction

SELECT vend_name,prod_name,prod_price from vendors INNER JOIN products 

Join multiple tables

SELECT Prod_name, vend_name,prod_price,quanity from Orderitems,products,vendors WHERE product.vend_id =vendors.

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.