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.