PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] unit of messurement table is required if there i'm going to store two record in database

 March 12, 2022     lamp, mysql, php     No comments   

Issue

In my e-commerce application there are several products available in two units i.e. product "X" has two types of packaging

  1. 200 gram
  2. 400 gram

Is there any need for creating Unit_Of_Mesurement table? If not then what is the solution or is there any other solution?


Solution

For an e-commerce site where a given product may be sold in different packages, you can either have each product package stored as a separate product, or use a second table to store the different formats of the product, where the rest of the generic product info is taken from a main product table.

For example, you'd have a product table, that contains information that applies to the product regardless of which format is being considered:

ID | name      | brand
--------------------------
 1 | Product 1 | ACME Corp
 2 | product 2 | ACME Corp

And then you'd have a product_format table, which contains the different packaging variations that product might have. If a product isn't sold in any different formats, then you could just have a single row here that contains the price, without specifying the format, since you won't need to show that information.

ID | product_ID | format | price
----------------------------------
 1 | 1          | 200g   | 19.99
 2 | 1          | 400g   | 37.99
 3 | 2          | null   | 8.99


Answered By - Raptord
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing