Edward Posted October 1, 2014 Share Posted October 1, 2014 I love the new book its well written. I found that if you have a website with buyers and sellers and not just an individual seller the carts database is not suffice. I think that in this case it would be best to create a cart and a cart_content database like this to make it easier to sort out members shopping carts with some simple relational queiries as apposed to some PHP logic. CREATE TABLE cart (id INT UNSIGNED NOT NULL AUTO_INCREMENT,buyer_id INT UNSIGNED NOT NULL,seller_id INT UNSIGNED NOT NULL,date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,date_updated DATETIME DEFAULT NULL,PRIMARY KEY (id),INDEX fk_cart_user_buyer_idx (buyer_id ASC),INDEX fk_cart_user_seller_idx (seller_id ASC))ENGINE=InnoDB;CREATE TABLE cart_content (id INT UNSIGNED NOT NULL AUTO_INCREMENT,cart_id INT UNSIGNED NOT NULL,item_id INT UNSIGNED NOT NULL,price INT UNSIGNED NOT NULL,quantity INT UNSIGNED NOT NULL DEFAULT 1,date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,date_updated DATETIME DEFAULT NULL,PRIMARY KEY (id),INDEX fk_cart_content_cart_idx (cart_id ASC),INDEX fk_cart_content_item_idx (item_id ASC))ENGINE=InnoDB; Link to comment Share on other sites More sharing options...
Larry Posted October 2, 2014 Share Posted October 2, 2014 Thanks for the nice words and thanks for sharing how you've evolved it! Link to comment Share on other sites More sharing options...
Recommended Posts