Posts

Showing posts with the label One to Many relationship

Design a database schema for an online merch store

Image
Designing a database schema for an online merchandise store involves considering various entities and their relationships. 1. Entities: A. Users: - UserID (Primary Key) - Username - Password - Email - Address - Phone number B. Products: - ProductID (Primary Key) - Name - Description - Price - CategoryID (Foreign Key) C. Categories: - CategoryID (Primary Key) - Name D. Orders: - OrderID (Primary Key) - UserID (Foreign Key) - OrderDate - TotalPrice E. OrderItems: - OrderItemID (Primary Key) - OrderID (Foreign Key) - ProductID (Foreign Key) - Quantity - Price 2. Relationships : - Each user can have multiple orders, but each order belongs to only one user. (One-to-Many relationship between Users and Orders) - Each order can contain multiple items, and each item can belong to multiple orders. (Many-to-Many relationship between Orders