Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Create a table for prices

Create a table for prices

Scheduled Pinned Locked Moved Database
help
5 Posts 4 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MedZi2010
    wrote on last edited by
    #1

    Hi, I wanna ask if I can put just one table for both prices an cities. In the beginning I created just table Product, but I have two different prices by cities(each city has a particular price). After that I put two tables one for cities and one prices. but I think I don't need table cities, I'm asking if I can create one table prices with field city. my data base NOW contains : Table Products: ProductID,ProductCode,ProductName,CityID,SubCategoryID... Table Cities: CityID,PriceID,City Name. Table Prices : PriceID,Price Table OrderDetails: OrderDetailsID, OrderID, FK ProductID, UnitPrice Table order OrderID, CostomerID,... The problem with prices : there are many prices for same product when they ordered (each city has a different price)

    A S M 3 Replies Last reply
    0
    • M MedZi2010

      Hi, I wanna ask if I can put just one table for both prices an cities. In the beginning I created just table Product, but I have two different prices by cities(each city has a particular price). After that I put two tables one for cities and one prices. but I think I don't need table cities, I'm asking if I can create one table prices with field city. my data base NOW contains : Table Products: ProductID,ProductCode,ProductName,CityID,SubCategoryID... Table Cities: CityID,PriceID,City Name. Table Prices : PriceID,Price Table OrderDetails: OrderDetailsID, OrderID, FK ProductID, UnitPrice Table order OrderID, CostomerID,... The problem with prices : there are many prices for same product when they ordered (each city has a different price)

      A Offline
      A Offline
      Anish_Chakraborty
      wrote on last edited by
      #2

      Well, there are multiple ways to solve a problem. It depends on whether you want to achieve speed or whether you want to have a normalized database. Here's what I would have done: Have a table called Products: ProductID, ProductCode, ProductName,... Have a table called Cities: CityID, City Name Have a table called Prices: PriceID, Price Have a table for mapping products with prices and cities, ProductPrice: ProductID, CityID, PriceID Pro: This way your data remains in a normalized form which is considered to be a good design approach. Con: You have to perform multiple joins while fetching data which will hamper performance a bit. But, I don't think you have millions of cities. So, I won't be bothered much with that. Hope it helped. :)

      D 1 Reply Last reply
      0
      • M MedZi2010

        Hi, I wanna ask if I can put just one table for both prices an cities. In the beginning I created just table Product, but I have two different prices by cities(each city has a particular price). After that I put two tables one for cities and one prices. but I think I don't need table cities, I'm asking if I can create one table prices with field city. my data base NOW contains : Table Products: ProductID,ProductCode,ProductName,CityID,SubCategoryID... Table Cities: CityID,PriceID,City Name. Table Prices : PriceID,Price Table OrderDetails: OrderDetailsID, OrderID, FK ProductID, UnitPrice Table order OrderID, CostomerID,... The problem with prices : there are many prices for same product when they ordered (each city has a different price)

        S Offline
        S Offline
        Sandeep Mewara
        wrote on last edited by
        #3

        Based on what you say, it sounds like there is one price per city. If so, I will differ a little from above answer. I would have designed as: Have a table called MstProducts: ProductID, ProductCode, ProductName, CityID, ... Have a table called MstCities: CityID, City Name, Price This covers 'each city has different price' and is also normalized.

        Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

        1 Reply Last reply
        0
        • A Anish_Chakraborty

          Well, there are multiple ways to solve a problem. It depends on whether you want to achieve speed or whether you want to have a normalized database. Here's what I would have done: Have a table called Products: ProductID, ProductCode, ProductName,... Have a table called Cities: CityID, City Name Have a table called Prices: PriceID, Price Have a table for mapping products with prices and cities, ProductPrice: ProductID, CityID, PriceID Pro: This way your data remains in a normalized form which is considered to be a good design approach. Con: You have to perform multiple joins while fetching data which will hamper performance a bit. But, I don't think you have millions of cities. So, I won't be bothered much with that. Hope it helped. :)

          D Offline
          D Offline
          Davidduraisamy
          wrote on last edited by
          #4

          Maintain normalized database whereas you can avoid redundancy and if you are not maintaining more cities for one city then you can go for same table.

          1 Reply Last reply
          0
          • M MedZi2010

            Hi, I wanna ask if I can put just one table for both prices an cities. In the beginning I created just table Product, but I have two different prices by cities(each city has a particular price). After that I put two tables one for cities and one prices. but I think I don't need table cities, I'm asking if I can create one table prices with field city. my data base NOW contains : Table Products: ProductID,ProductCode,ProductName,CityID,SubCategoryID... Table Cities: CityID,PriceID,City Name. Table Prices : PriceID,Price Table OrderDetails: OrderDetailsID, OrderID, FK ProductID, UnitPrice Table order OrderID, CostomerID,... The problem with prices : there are many prices for same product when they ordered (each city has a different price)

            M Offline
            M Offline
            MedZi2010
            wrote on last edited by
            #5

            Thank you guys. I appreciated.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups