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.
  • 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