and the following example,+-------------+ +------------------+ | Products | | Supplier_Product | +-------------+ +------------------+ | PNO | PNAME | | SNO | PNO | +-----+-------+ +---------+--------+ | P1 | Screw | | S1 | P1 | | P1 | Screw | | S1 | P1 | | P1 | Screw | | S1 | P2 | | P2 | Screw | +------------------+ +-------------+
The two sets of tables have the same structure, but duplicate rows are valid in the second case. Three screws were purchased on December 1st, and FedEx dropped off 2 packages on December 1st. You don't know which screws belongs to which package, but one would assume that you don't need to perform that link if you structured the tables in this manner. Also, you may or may not want to use DISTINCT, depending on whether or not you want to know that 3 screws were delivered, or you just want to know that screws were delivered.+--------------------+ +-------------------------------+ | Purchased_Items | | Package_Deliveries | +--------------------+ +-------------------------------+ | Date | Item | | Delivery_Company | Date | +------------+-------+ +------------------+------------+ | 2005/12/01 | Screw | | FedEx | 2005/12/01 | | 2005/12/01 | Screw | | FedEx | 2005/12/01 | | 2005/12/01 | Screw | | FedEx | 2005/12/02 | | 2005/12/02 | Screw | +-------------------------------+ +--------------------+
In reply to Re: (OT) Why SQL Sucks (with a little Perl to fix it)
by Anonymous Monk
in thread (OT) Why SQL Sucks (with a little Perl to fix it)
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |