Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • I'm a little confused. What does the productID value actually signify here? Are you saying that a single product can have multiple productID values depending on which description is used? Commented Apr 26, 2017 at 19:13
  • Are the common fields of the product located in Product table? Or It's just a table for relationships? For the second case it',s just unecessary because It looks like a one-to-one relationship. The name also could lead to confusion. Commented Apr 26, 2017 at 19:27
  • @Andrew, the productId is an auto generated (incrementing) id in the database. It's a surrogate key. A productId should refer to 1 & only 1 real world product. Each data source may have its own data about that product and the DB must capture that. Suppose we have an iron door. If it's the first product inserted into the DB it will be given a productId of 1. Now, data source A may give a description of "fine door". Data source B may give the same iron door a description of "old iron door". So, DataSourceProduct will have 2 rows (1 row for each data source). Both rows will have productId = 1. Commented Apr 26, 2017 at 19:49
  • 1
    @James Then I would change the name to the table because It's confusing. It's rather a SKU than a Product. Also many-to-one relationship can be implemented with two tables only. The table Product, IMO, is adding complexity to the model. Commented Apr 26, 2017 at 19:59
  • 1
    @James I'm not sure I agree with Laiv about condensing to two tables. It seems that the DataSourceProduct table (which may be misnamed) embodies the relationship between the dataSource and the Product. I assume the product table contains many other details about the product, other than the DataSource-associated name? Anyway I would probably create objects for each of these tables and define the relationships between them using JPA notation. I don't see much inheritance since they each contain their own relevant fields -- which is probably why you should rename. Commented Apr 26, 2017 at 20:59