Many-to-One Joining in Databases

Discussion in 'Technology' started by Mixt, May 3, 2012.

  1. Mixt The dude that does the thing

    Joined:
    Oct 18, 2006
    Gender:
    Male
    826
    I feel like this should be easier than it is turning out to be, so hopefully someone can help me. Sorry in advance if this is unclear or if I mix up terms. I'm still pretty new at this.

    Me and my professor are "discussing" if an example in the textbook is possible in real life. The example is a hypothetical store keeping an inventory database and the use of table relation to form a query on when the store will have enough stock to complete an order. It hinges on the joining of a current inventory table and a shipment table. The issue is that the Shipment table uses a primary key of a Shipment ID and the Inventory uses a Product ID. While the shipment table does list the product IDs there can be multiple shipments of the same item, thus not making it a One-to-One relation. He believes that since they do not share a primary key the two tables cannot be joined and therefor cannot be related, period end of story. However since the Shipment table does list the Product ID which can only correspond to one record on the Inventory table I think the two can be logically joined. In fact if we were to exit the realm of databases and use CSV tables I'm fairly sure I could make an AHK script to do the joining. But in the context of SQL I'm lost on how to do so. The best I can think right now is that maybe we use SQL only to retrieve the data and I can use another program to actually manipulate the data.