E Product ProductID: int Name: string Barcode string ManufacturerID : int E Consumer Email: string sold in sells (E) FoodProduct // Inherits ProductID, Name, Barcode, ManufacturerID from Product Expiry Date date E NonFoodProduct // Inherits ProductID, Name, Barcode, ManufacturerID from Product WarrantyPeriod: string E Manufacturer ManufacturerID : int Name: string Address string PhoneNumber: string Email: string E Store StoreID: int Name: string Address string PhoneNumber: string Email: string StoreLocation: string E Ingredient IngredientID : int Item: string Source: string E NutritionalDetail NutritionalDetailID : int Item: string Amount: string
Write the SQL code to create the relational schemas from this data base system :
Entities and Attributes
1. Product
- Attributes:
- ProductID (PK): Unique identifier for each product.
- Name: Name of the product.
- Barcode: Barcode for the product.
- ManufacturerID (FK): Foreign key referencing the Manufacturer.
- Category: Dietary category of the product (e.g., vegan, vegetarian).
- Assumption: Each product has a unique identifier and is associated with a manufacturer and dietary category.
2. Manufacturer
- Attributes:
- ManufacturerID (PK): Unique identifier for each manufacturer.
- Name: Name of the manufacturer.
- Address: Address of the manufacturer.
- PhoneNumber: Contact number.
- Email: Contact email.
- Assumption: Manufacturers produce multiple products.
3. Store
- Attributes:
- StoreID (PK): Unique identifier for each store.
- Name: Name of the store.
- Address: Address of the store.
- PhoneNumber: Contact number.
- Email: Contact email.
- StoreLocation: Location of the store.
- Assumption: Stores sell multiple products.
4. Ingredient
- Attributes:
- IngredientID (PK): Unique identifier for each ingredient.
- Item: Name of the ingredient.
- Source: Source of the ingredient.
- Assumption: Each product consists of multiple ingredients.
5. NutritionalDetail
- Attributes:
- NutritionalDetailID (PK): Unique identifier for each nutritional detail.
- Item: Nutritional item (e.g., calories, protein).
- Amount: Amount of the nutritional item.
- Assumption: Each product has multiple nutritional details.
6. Consumer
- Attributes:
- Email (PK): Email of the consumer.
- Assumption: Consumers can suggest products, and only their email is stored.
Relationships
1. Product-Manufacturer: A product is manufactured by one manufacturer, and a manufacturer can produce many products.
- Type: One-to-Many
- Explanation: The ManufacturerID in the Product entity references the Manufacturer entity.
2. Product-Store: A product can be sold in many stores, and a store can sell many products.
- Type: Many-to-Many
- Explanation: This relationship is represented using an associative entity (e.g., ProductStore), which connects ProductID and StoreID.
3. Product-Ingredient: A product can have many ingredients, and an ingredient can be part of many products.
- Type: Many-to-Many
- Explanation: This relationship is represented using an associative entity (e.g., ProductIngredient), which connects ProductID and IngredientID.
4. Product-NutritionalDetail: A product can have many nutritional details, and each nutritional detail is associated with one product.
- Type: One-to-Many
- Explanation: The NutritionalDetailID in the Product entity references the NutritionalDetail entity.
5. Consumer-Product: Consumers can request to add products.
- Type: Optional One-to-Many
- Explanation: No direct relationship is stored in the database, but consumers can suggest products, and only their email is recorded if they request it.
Subtype/Supertype Hierarchy (EER Specific)
- Supertype Product: General entity for all products.
- Subtypes FoodProduct and NonFoodProduct: Specific types of products inheriting from Product.
- FoodProduct Attributes:
- ExpiryDate: Expiry date of the food product.
- NonFoodProduct Attributes:
- WarrantyPeriod: Warranty period of the non-food product.
- FoodProduct Attributes:
![E Product
ProductID: int
Name: string
Barcode string
ManufacturerID : int
E Consumer
Email: string
sold in
sells
(E) FoodProduct
// Inherits ProductID, Name, Barcode, ManufacturerID from Product
Expiry Date date
E NonFoodProduct
// Inherits ProductID, Name, Barcode, ManufacturerID from Product
WarrantyPeriod: string
E Manufacturer
ManufacturerID : int
Name: string
Address string
PhoneNumber: string
Email: string
E Store
StoreID: int
Name: string
Address string
PhoneNumber: string
Email: string
StoreLocation: string
E Ingredient
IngredientID : int
Item: string
Source: string
E NutritionalDetail
NutritionalDetailID : int
Item: string
Amount: string](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F602caea4-3d4d-49a2-a5cf-03841bb038cc%2F65dafa33-97b8-45f9-ba1c-f7885cabd1e1%2Fw8z6mg_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)