need some opinions here

Results 1 to 2 of 2

Thread: need some opinions here

  1. #1
    Joel M Guest

    Default need some opinions here

    I&#039m working on what will someday be a site that sells computers and stuff []...I&#039m thinking of making a table to hold product issues, the problem that I run into (and it may be because I haven&#039t thought it through) is that I don&#039t know how to make it apply to multiple products.<BR>example:<BR>-------------------------<BR> if there was an issue with a USB product, I would make an issue that has the "item_id" and when I query that DB with that number, it would pop right up.<BR><BR> but if there was an issue that affected...say 3 items. how would I make it so that I could query the DB with any 3 of those numbers, and it pop up?<BR>----------------------------<BR><BR>this is more of a database theory/design problem than anything technical...thanks in advance.<BR><BR>Joel

  2. #2
    Garth Guest

    Default RE: need some opinions here

    Use a junction table to resolve the many-to-many. I am going to change the names a bit...<BR><BR>CREATE TABLE Product<BR>(<BR> Product_ID int<BR> Product_Description varchar(30)<BR>)<BR><BR>CREATE TABLE Issue<BR>(<BR> Issue_ID int<BR> Issue_Description varchar(30)<BR>)<BR><BR>CREATE TABLE ProductsIssues<BR>(<BR> Product_ID int,<BR> Issue_ID int<BR>)<BR><BR>When you want to know what Products are affected by a particular issue, you would use something like...<BR><BR>SELECT Product_Descripton<BR>FROM Products a<BR>INNER JOIN ProductsIssues b ON a.Product_ID on b.Product_ID AND b.Issue_ID = @VariableThatContainsIssueID<BR><BR><BR><BR>Garth< BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts