3

I have the following scenario in my database: Simple Product-Cart database

With this structure, I can show the following information to my user:

"Your cart has 2 products, with the total of $400

  • Product 1, $100
  • Product 2, $300
  • Total: $400 ".

My company wants to sell products inside groups to give discounts to its customers. And I need to show information like this:

"You are buying Product Group 1 which has the following products:

  • Product 1, $100
  • Product 2, $300
  • Product 3, $240 .... Total: $1000".

So I've remodelled the database to something like this: Remodeled Database

But I'm facing some problems, and would like to know if this the best way to work with item grouping in an ecommerce application?

A customer can choose this package into his cart with (or without) other individual products, what kind of generalization can be used here?

Joe Ratzer
  • 18,176
  • 3
  • 37
  • 51
Felipe Francisco
  • 1,064
  • 2
  • 21
  • 45
  • I haven't done anything in the ecommerce domain, but things might be simpler if "groups" were simply entries in `product` that have "component" products; or, alternately, the cart only actually holds "groups", but most groups only contain single items. – Uueerdo May 05 '15 at 19:32
  • I would take away the link between item and group. Also, I would rename group because it's an sql reserved word and may cause headaches. – Dan Bracuk May 05 '15 at 19:41
  • @Uueerdo Thanks, but using this method the application would only be selling "groups", I don't know if this would be the best solution :\ – Felipe Francisco May 05 '15 at 20:03
  • @DanBracuk Thanks, if I took away this link, how could I sell groups of products? That's my need :\ – Felipe Francisco May 05 '15 at 20:04
  • @FelipeFrancisco, I suggested it because only selling in groups is actually a benefit; otherwise you'll need to handle two different "things" in the cart. This way can simplify overall logic. – Uueerdo May 05 '15 at 20:05
  • possible duplicate of [database model for products and product package with different combinations](http://stackoverflow.com/questions/14527203/database-model-for-products-and-product-package-with-different-combinations) – Neil McGuigan May 05 '15 at 21:36
  • @NeilMcGuigan It's **kinda** like that, but not totally equal. This links leads to a question where costumers choose itens and depending on which itens they choose, a discount is applied (right?). My question is about a package that already exists and the costumer can choose this package into his cart with (or without) other individual products... But thanks, the diagram in the answers of that question gave me some ideas. – Felipe Francisco May 05 '15 at 21:46

1 Answers1

0

You do not need to create the extra table, you need to be able to let products have a master product and a add a product type code to the table.

That way you could have product 2 and 3 link to product 1. If you add product 1 to your basket 2 and 3 are added. But if you buy 2 or 3, the others are not automatically added to your basket.

You use the type code field to make it easier to identify the product:

for example:

  • Type code 1: Normal product
  • Type code 2: set
  • Type code 3: Part of set

Hope this helps. This is just from the top of my head on how you could handle this, you can use type codes and links between the other products for other things.

Thomas Theunen
  • 1,244
  • 9
  • 13