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. General Programming
  3. C#
  4. how to Save Matrix

how to Save Matrix

Scheduled Pinned Locked Moved C#
tutorialquestion
5 Posts 2 Posters 0 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.
  • G Offline
    G Offline
    Greeky
    wrote on last edited by
    #1

    Imagine a matrix, S M L XL color1 10 20 30 0 color2 4 5 45 50 color3 1 0 4 5 You a sample matrix what i work on. columns are quantity of sizes (some of them may equals to 0 ) . Rows are colors. rows count and columns count are variable. How to save them to data base. rows are in a table, size are saved on other table. But i couldnt solve how to save values on table. what do you offer to me ?

    G 1 Reply Last reply
    0
    • G Greeky

      Imagine a matrix, S M L XL color1 10 20 30 0 color2 4 5 45 50 color3 1 0 4 5 You a sample matrix what i work on. columns are quantity of sizes (some of them may equals to 0 ) . Rows are colors. rows count and columns count are variable. How to save them to data base. rows are in a table, size are saved on other table. But i couldnt solve how to save values on table. what do you offer to me ?

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Store the sizes in one table, the model in one table, and the quantities in one table. Size (SizeId int, SizeName varchar) 1, 'S' 2, 'M' 3, 'L' 4, 'XL' Model (ModelId int, ModelName varchar) 1, 'color1' 2, 'color2' 3, 'color3' ModelQuantity (ModelId int, SizeId int, Quantity int) 1, 1, 10 1, 2, 20 1, 3, 30 1, 4, 0 2, 1, 4 2, 2, 5 2, 3, 45 2, 4, 50 3, 1, 1 3, 2, 0 3, 3, 4 3, 4, 5 Alternatively, you can choose to not store any record for the quantities that are zero. --- b { font-weight: normal; }

      G 1 Reply Last reply
      0
      • G Guffa

        Store the sizes in one table, the model in one table, and the quantities in one table. Size (SizeId int, SizeName varchar) 1, 'S' 2, 'M' 3, 'L' 4, 'XL' Model (ModelId int, ModelName varchar) 1, 'color1' 2, 'color2' 3, 'color3' ModelQuantity (ModelId int, SizeId int, Quantity int) 1, 1, 10 1, 2, 20 1, 3, 30 1, 4, 0 2, 1, 4 2, 2, 5 2, 3, 45 2, 4, 50 3, 1, 1 3, 2, 0 3, 3, 4 3, 4, 5 Alternatively, you can choose to not store any record for the quantities that are zero. --- b { font-weight: normal; }

        G Offline
        G Offline
        Greeky
        wrote on last edited by
        #3

        i already did so , but i think it is not effective way. When reports i show these values as a table (using listview object). But it is hard to populate values in to a listview. First i read just columns for creating column header Then i try to read values at ModelQuantity for rows. Care that all color1 values must be at the same row. So after for datareader.read process , i create a listviewitem object.

        G 1 Reply Last reply
        0
        • G Greeky

          i already did so , but i think it is not effective way. When reports i show these values as a table (using listview object). But it is hard to populate values in to a listview. First i read just columns for creating column header Then i try to read values at ModelQuantity for rows. Care that all color1 values must be at the same row. So after for datareader.read process , i create a listviewitem object.

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          It's the best way if you consider possible changes in the future. You can for an example add the size "XXL" without having to change the data model. If you give up that flexibility, you could store all sizes for a model in a single record, with each quantity in a field. This would make it simpler to get the data, but if you need to add a size it requires changes in the database and in the code. --- b { font-weight: normal; }

          G 1 Reply Last reply
          0
          • G Guffa

            It's the best way if you consider possible changes in the future. You can for an example add the size "XXL" without having to change the data model. If you give up that flexibility, you could store all sizes for a model in a single record, with each quantity in a field. This would make it simpler to get the data, but if you need to add a size it requires changes in the database and in the code. --- b { font-weight: normal; }

            G Offline
            G Offline
            Greeky
            wrote on last edited by
            #5

            that is why i ask for :) (XXL or XS or any other numeric sizes. ) i search for any easier other way but i think there is no possibility :( ,thank you for reply

            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