Book now with code EOY2025
SELECT dbo.Products.Title, dbo.Products.RegionID, dbo.Users.Username, dbo.Users.FirstName, dbo.Users.EmailAddress, dbo.Regions.RegionNameFROM dbo.Products INNER JOIN dbo.Regions ON dbo.Products.RegionID = dbo.Regions.ID INNER JOIN dbo.Users ON dbo.Products.UserID = dbo.Users.ID AND dbo.Regions.ID = dbo.Users.RegionID WHERE (dbo.Products.RegionID = 6)
CarlSaiyed wrote: » Edit: Looking close at your diagram you have the userID in the products table. This would mean to me that each product can only be associated with one user. If this is correct then your don't need another table. Can you clarify the intended relationship?
mishy wrote: » I did not have any ideas on how the relationship of the third table would be since I thought I had met all the desired objectives by adding the user ID in the products page. Yes, a product can only have one user associated with it. Thanks to everyone for the responses, I think I might go ahead with the idea of adding a location and then creating a third table that joins the user and the product together based on location.
knownhero wrote: » That's what I would do to start off with. Then you can create views etc to see what's in my area.
RobertKaucher wrote: » I think we are kind of getting ahead of ourselves as you have not actually explained your requirements. Is the correct relationship in your model that each USER should have 0 or more products and that each PRODUCT must have only 1 user? Also, if you use REGIONS as a junction in the way depicted there will be a couple of issues: 1. A user and his products could have different regions. (Is that what you expect?) 2. A user can only be associated with 1 region (what if I want to advertise for products in the city where I live and where I work?)
RobertKaucher wrote: » I understand. My point was really just that we did not know the specification that you were given for your data model. In your original post, you showed your existing model and said that it was incomplete because you were told you'd need at least 3 tables but not what that third table will do. Some people came up with good guesses, but without knowing what the relationship was intended it's hard to say. I also wanted to stress that choosing any given model will always have advantages and disadvantages. But you are probably are aware of that.
Use code EOY2025 to receive $250 off your 2025 certification boot camp!