Edward 108 Posted October 1, 2014 Report 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; Quote Link to post Share on other sites
Larry 429 Posted October 2, 2014 Report Share Posted October 2, 2014 Thanks for the nice words and thanks for sharing how you've evolved it! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.