I have a problem with finding relations between tables ps_product and ps_carrier from a prestashop database. The schema is available at http://doc.prestashop.com/display/PS16/Fundamentals+of+PrestaShop+Development.
I need to make an update by joining these two tables in my shop but I'm struggling with finding good keys. How do I compose my query?
Tables represent business relationships/associations. The "relation[ship]s" you mention are FKs (foreign keys), and which are not needed for querying. They state that subrow values for some columns must also be subrow values for some key columns. What is needed is to know what a row says about the current business situation when it is in a table. (Which, given what situations arise, determine the FKs and other constraints.)
From Required to join 2 tables with their FKs in a 3rd table:
So given
we write
to get rows where
You need know your tables' predicates then JOIN together tables ON or WHERE conditions so that the resulting predicate is for the rows you want back.
Is there any rule of thumb to construct SQL query from a human-readable description?