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. Other Discussions
  3. The Soapbox
  4. Wasting bytes

Wasting bytes

Scheduled Pinned Locked Moved The Soapbox
databasequestion
19 Posts 15 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.
  • J jesarg

    Am I the only one who is annoyed by systematic wasting of database bytes? It seems as if everyone uses the "int" type because they are too lazy to use smallint or tinyint. We even have standards that force us to use the "int" type for values that are never going to go higher than 10 or 20. Tables such as: PaymentType 0 = Cash 1 = Check 2 = Credit card 3 = Money order You know we're never going to invent more than 255 ways of paying for stuff, and we're certainly never inventing more than 32 thousand ways of paying for stuff, so why do we have to make the ID column an int? Maybe if we're bombed into the stone age and forced to barter using cows, sheep, and cartloads of asparagus, we'll have 32 thousand different ways of paying, but I imagine if that happens, the financial software we're writing will be absolutely useless, anyway.

    S Offline
    S Offline
    Single Step Debugger
    wrote on last edited by
    #5

    I have a better things to do than trying to outsmart the future with predictions what numeric type every field should be. Besides In a big system (hundreds or thousands of tables) it will be a recipe for disaster. All this integer types will have to use according variable types in the store procedures, functions and in the client (if you have a multiple middle tiers the fun will be endless) just to avoid data truncation.

    There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

    1 Reply Last reply
    0
    • T thrakazog

      I've had to make several database changes this year based on somebodies assumption that there would never be over 32K of entries in a series of tables. Million dollar order entry software crashing because somebody had to save a few bytes and use smallint or tinyint. Hard drives are cheap, programming hours are not. Use INT, use it everywhere, even if you think you'll never need that many numbers.

      Kill some time, play my game Hop Cheops[^]

      S Offline
      S Offline
      Single Step Debugger
      wrote on last edited by
      #6

      :thumbsup:

      There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

      1 Reply Last reply
      0
      • J jesarg

        Am I the only one who is annoyed by systematic wasting of database bytes? It seems as if everyone uses the "int" type because they are too lazy to use smallint or tinyint. We even have standards that force us to use the "int" type for values that are never going to go higher than 10 or 20. Tables such as: PaymentType 0 = Cash 1 = Check 2 = Credit card 3 = Money order You know we're never going to invent more than 255 ways of paying for stuff, and we're certainly never inventing more than 32 thousand ways of paying for stuff, so why do we have to make the ID column an int? Maybe if we're bombed into the stone age and forced to barter using cows, sheep, and cartloads of asparagus, we'll have 32 thousand different ways of paying, but I imagine if that happens, the financial software we're writing will be absolutely useless, anyway.

        K Offline
        K Offline
        killabyte
        wrote on last edited by
        #7

        Guilty as charged but i have been burnt by int rollovers before so if im in doubt "bigint" i shout!!!

        1 Reply Last reply
        0
        • T thrakazog

          I've had to make several database changes this year based on somebodies assumption that there would never be over 32K of entries in a series of tables. Million dollar order entry software crashing because somebody had to save a few bytes and use smallint or tinyint. Hard drives are cheap, programming hours are not. Use INT, use it everywhere, even if you think you'll never need that many numbers.

          Kill some time, play my game Hop Cheops[^]

          J Offline
          J Offline
          jesarg
          wrote on last edited by
          #8

          I agree that whenever you're in doubt, use the bigger value, especially if a user application can add rows to the table. But some of these tables are basically a list of eunms which never get new rows unless a programmer deliberately adds one as a result of a change request. Maybe disk space is so cheap that it will never matter, but it always looks bad.

          1 Reply Last reply
          0
          • R R Giskard Reventlov

            Well I, for one, try to use an appropriate type but I do see it all the time. My biggest niggle is using a char field as a psudo boolean (you know, yes/no). Aggh??? Why???

            "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

            V Offline
            V Offline
            V 0
            wrote on last edited by
            #9

            Oracle doesn't have a bool field. There often 0/1 or T/F is used.

            V.

            1 Reply Last reply
            0
            • J jesarg

              Am I the only one who is annoyed by systematic wasting of database bytes? It seems as if everyone uses the "int" type because they are too lazy to use smallint or tinyint. We even have standards that force us to use the "int" type for values that are never going to go higher than 10 or 20. Tables such as: PaymentType 0 = Cash 1 = Check 2 = Credit card 3 = Money order You know we're never going to invent more than 255 ways of paying for stuff, and we're certainly never inventing more than 32 thousand ways of paying for stuff, so why do we have to make the ID column an int? Maybe if we're bombed into the stone age and forced to barter using cows, sheep, and cartloads of asparagus, we'll have 32 thousand different ways of paying, but I imagine if that happens, the financial software we're writing will be absolutely useless, anyway.

              G Offline
              G Offline
              GuyThiebaut
              wrote on last edited by
              #10

              I see where you are coming from with regards to what is known about a particular set of data at the moment. However I have seen on occasion cases where in the example you give you may want a value of 9999 to reference a refund for example. Sometimes you want a value at the extreme end of a range so that your logic can use between comparisons rather than individually listing values as in the refund example above. I did my IT degree at the end of the 80's when memory was expensive and we were taught to calculate the amount of space required - nowadays with memory being cheap this is not such an issue. For what it's worth I would say always build in the possibility of expansion into a system...

              “That which can be asserted without evidence, can be dismissed without evidence.”

              ― Christopher Hitchens

              1 Reply Last reply
              0
              • J jesarg

                Am I the only one who is annoyed by systematic wasting of database bytes? It seems as if everyone uses the "int" type because they are too lazy to use smallint or tinyint. We even have standards that force us to use the "int" type for values that are never going to go higher than 10 or 20. Tables such as: PaymentType 0 = Cash 1 = Check 2 = Credit card 3 = Money order You know we're never going to invent more than 255 ways of paying for stuff, and we're certainly never inventing more than 32 thousand ways of paying for stuff, so why do we have to make the ID column an int? Maybe if we're bombed into the stone age and forced to barter using cows, sheep, and cartloads of asparagus, we'll have 32 thousand different ways of paying, but I imagine if that happens, the financial software we're writing will be absolutely useless, anyway.

                Z Offline
                Z Offline
                ZurdoDev
                wrote on last edited by
                #11

                NVARCHAR(MAX)

                for everything, because you never know.

                M 1 Reply Last reply
                0
                • R R Giskard Reventlov

                  Well I, for one, try to use an appropriate type but I do see it all the time. My biggest niggle is using a char field as a psudo boolean (you know, yes/no). Aggh??? Why???

                  "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #12

                  You have to! A bool just doesn't hold enough information: I want yes, no and maybe. :-D

                  Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  L R 2 Replies Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    You have to! A bool just doesn't hold enough information: I want yes, no and maybe. :-D

                    Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #13

                    In Progress a LOGICAL can be TRUE, FALSE, or ? - which is unknown.

                    Every man can tell how many goats or sheep he possesses, but not how many friends.

                    OriginalGriffO 1 Reply Last reply
                    0
                    • L Lost User

                      In Progress a LOGICAL can be TRUE, FALSE, or ? - which is unknown.

                      Every man can tell how many goats or sheep he possesses, but not how many friends.

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #14

                      I have seen code that went:

                          void MyMethod(bool b)
                              {
                              if (b == true)
                                  {
                                  ...
                                  }
                              else if (b == false)
                                  {
                                  ...
                                  }
                              else
                                  {
                                  ...
                                  }
                              }
                      

                      And to think I assumed they were idiots! :doh:

                      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        You have to! A bool just doesn't hold enough information: I want yes, no and maybe. :-D

                        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                        R Offline
                        R Offline
                        R Giskard Reventlov
                        wrote on last edited by
                        #15

                        You need a trinary field, not a boolean then.

                        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                        1 Reply Last reply
                        0
                        • Z ZurdoDev

                          NVARCHAR(MAX)

                          for everything, because you never know.

                          M Offline
                          M Offline
                          Mycroft Holmes
                          wrote on last edited by
                          #16

                          Bang - that was the door closing behind your fired ass.. oh wait a joke icon :-O

                          Never underestimate the power of human stupidity RAH

                          1 Reply Last reply
                          0
                          • J jesarg

                            Am I the only one who is annoyed by systematic wasting of database bytes? It seems as if everyone uses the "int" type because they are too lazy to use smallint or tinyint. We even have standards that force us to use the "int" type for values that are never going to go higher than 10 or 20. Tables such as: PaymentType 0 = Cash 1 = Check 2 = Credit card 3 = Money order You know we're never going to invent more than 255 ways of paying for stuff, and we're certainly never inventing more than 32 thousand ways of paying for stuff, so why do we have to make the ID column an int? Maybe if we're bombed into the stone age and forced to barter using cows, sheep, and cartloads of asparagus, we'll have 32 thousand different ways of paying, but I imagine if that happens, the financial software we're writing will be absolutely useless, anyway.

                            V Offline
                            V Offline
                            Vivi Chellappa
                            wrote on last edited by
                            #17

                            IBM in its 360/370/3090 mainframes has something called Packed Decimal which would take half the amount of bytes that a regular decimal (Zoned Decimal in IBM-speak) would need. It gives grief to anyone who wants to read data from a mainframe and process it on a Unix box or PC.

                            1 Reply Last reply
                            0
                            • J jesarg

                              Am I the only one who is annoyed by systematic wasting of database bytes? It seems as if everyone uses the "int" type because they are too lazy to use smallint or tinyint. We even have standards that force us to use the "int" type for values that are never going to go higher than 10 or 20. Tables such as: PaymentType 0 = Cash 1 = Check 2 = Credit card 3 = Money order You know we're never going to invent more than 255 ways of paying for stuff, and we're certainly never inventing more than 32 thousand ways of paying for stuff, so why do we have to make the ID column an int? Maybe if we're bombed into the stone age and forced to barter using cows, sheep, and cartloads of asparagus, we'll have 32 thousand different ways of paying, but I imagine if that happens, the financial software we're writing will be absolutely useless, anyway.

                              A Offline
                              A Offline
                              Andy Brummer
                              wrote on last edited by
                              #18

                              I've used small and tiny ints in databases that handled millions to billions of transactions a day. It made sense there. I'm working on a lob app that uses smallints even though the entire database is under a Gig and it means I have to write extra code to handle those objects with non-integer primary keys which is a pain in the ass. It all depends on context.

                              Curvature of the Mind now with 3D

                              1 Reply Last reply
                              0
                              • R R Giskard Reventlov

                                Well I, for one, try to use an appropriate type but I do see it all the time. My biggest niggle is using a char field as a psudo boolean (you know, yes/no). Aggh??? Why???

                                "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                                D Offline
                                D Offline
                                Dave Kreskowiak
                                wrote on last edited by
                                #19

                                Funny you should mention that. I'm forced to do just that. Why? Because Microsoft's System Center Configuration Manager software uses the old MIF file format for importing hardware and software inventory into the SCCM database. Well, if you have a field in a custom inventory item, say one that specified a true/false value, the MIF specification doesn't support Boolean types! So, "True/False" it is! (This is was easier for upstream people to understand than it was for them to get that 1 = True, 0 = False.) Trust me, not my choice!

                                A guide to posting questions on CodeProject[^]
                                Dave Kreskowiak

                                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