title: ERD for ShoppingCart
body: <p>I'm a bit confused about the entity relationship diagram for my application.</p>
  
  <p>So far I have made tables for Product,Customer,Category</p>
  
  <p>Should I make a table for UserAccounts that holds the id and password for the Customer or directly place the the id and password in the Customer table?</p>
  
  <p>Secondly, each customer will have his own cart. So I have made a CartItem table</p>
  
  <p>CartItemId,
  ProductId,
  CategoryId,
  Description,
  UnitPrice,
  TotalPrice</p>
  
  <p>But this table is not associating a customer with the cartItem in the shoppingcart. So Should i add the CustomerId here also?</p>
  
  <p>Is there a need for Description and unit price, because those are already defined in the  Product Table?</p>
  
  <p>and for Cart Table,
         CartId,
         CartItemId,
         CustomerId</p>
  
  <p>I need to clear up a few things, before I find any mistakes in my application.</p>
  
  <p>DDL:</p>
  
  <pre><code>   CREATE DATABASE ShoppingCart
  
     Create Table Customer(
     CustomerId int PRIMARY KEY,
     Firstname varchar(50),
     Lastname varchar(50),
     Address varchar(50),
     City varchar(50),
     State varchar(50),
     Country varchar(50),
     Mobile varchar(50),
     Phone varchar(50),
     Email varchar(50)
     )
  
     Create Table UserAccount(
     UserName varchar(50),
     PasswordHash varchar(50)
     )
  
     Create Table Category(
     CategoryId int PRIMARY KEY,
     CategoryName varchar(50),
     CategoryDescription varchar(50),
     CategoryImage varchar(50)
     )
  
     Create Table Products(
     ProductId int PRIMARY KEY,
     ProductName varchar(50),
     Description varchar(50),
     CategoryId int,
     UnitPrice money,
     DateAdded datetime,
     thumn varchar(50),
  
     CONSTRAINT fk_CategoryId FOREIGN KEY (CategoryId)
     REFERENCES Category(CategoryId)
     )
  
  
  
  Create Table CartItem(
  CartItemId int,
  ProductId int,
  CategoryId int,
  Description varchar(50),
  UnitPrice money,
  TotalPrice money,
  
  PRIMARY KEY (CartItemId),
  CONSTRAINT fk_ProductId FOREIGN KEY (ProductId)
  REFERENCES Products(ProductId),
  
  CONSTRAINT fk_CartItem_CategoryId FOREIGN KEY (CategoryId)
  REFERENCES Category(CategoryId)
  
  )
  
  Create Table Cart(
  CartId int,
  CartItemId int,
  ProductId int,
  CategoryId int,
  Description varchar(50),
  UnitPrice money,
  TotalPrice money,
  
  PRIMARY KEY (CartId),
  
  CONSTRAINT fk_CartItemId FOREIGN KEY (CartItemId)
  REFERENCES CartItem(CartItemId),
  
  CONSTRAINT fk_CartItem_CategoryId FOREIGN KEY (CategoryId)
  REFERENCES Category(CategoryId),
  
  PRIMARY KEY (ProductId),
  CONSTRAINT fk_CartItemId FOREIGN KEY (ProductId)
  REFERENCES CProducts(productId)
  
  )
  </code></pre>