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. The Lounge
  3. Table column count competition

Table column count competition

Scheduled Pinned Locked Moved The Lounge
29 Posts 14 Posters 5 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.
  • V Offline
    V Offline
    Vasily Tserekh
    wrote on last edited by
    #1

    I have a table in the application i am developing of 155 columns i dare anyone to beat me:mad: ps. the table is already in 3rd normal form

    G A D E J 8 Replies Last reply
    0
    • V Vasily Tserekh

      I have a table in the application i am developing of 155 columns i dare anyone to beat me:mad: ps. the table is already in 3rd normal form

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

      Erm... :^) One database I worked on had a table that had to be split into two as there were more than 255 columns that were required for each row.... It's not as rare as it may sound particularly when you are dealing with something as complex as the human body(it was a medical database). That said - I am sure there are better ways of representing data than having so many columns populated for each row...

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

      ― Christopher Hitchens

      V P L T 4 Replies Last reply
      0
      • G GuyThiebaut

        Erm... :^) One database I worked on had a table that had to be split into two as there were more than 255 columns that were required for each row.... It's not as rare as it may sound particularly when you are dealing with something as complex as the human body(it was a medical database). That said - I am sure there are better ways of representing data than having so many columns populated for each row...

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

        ― Christopher Hitchens

        V Offline
        V Offline
        Vasily Tserekh
        wrote on last edited by
        #3

        guess I am one the 2nd place so far!!

        1 Reply Last reply
        0
        • G GuyThiebaut

          Erm... :^) One database I worked on had a table that had to be split into two as there were more than 255 columns that were required for each row.... It's not as rare as it may sound particularly when you are dealing with something as complex as the human body(it was a medical database). That said - I am sure there are better ways of representing data than having so many columns populated for each row...

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

          ― Christopher Hitchens

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          GuyThiebaut wrote:

          required for each row

          GuyThiebaut wrote:

          medical database

          I'm not convinced -- if the table had columns for right and left arm etc., what did you do for patients with missing arms? Leave NULLs? I'd prefer to have different tables for different body parts. :-D

          Mike HankeyM G 2 Replies Last reply
          0
          • G GuyThiebaut

            Erm... :^) One database I worked on had a table that had to be split into two as there were more than 255 columns that were required for each row.... It's not as rare as it may sound particularly when you are dealing with something as complex as the human body(it was a medical database). That said - I am sure there are better ways of representing data than having so many columns populated for each row...

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

            ― Christopher Hitchens

            L Offline
            L Offline
            lewax00
            wrote on last edited by
            #5

            GuyThiebaut wrote:

            I am sure there are better ways of representing data

            I would imagine in that case you could have broken it down into sections like specific body parts/systems. But then again I have no idea what the data looked like, it may not have been that simple (or not clearly divided enough).

            1 Reply Last reply
            0
            • V Vasily Tserekh

              I have a table in the application i am developing of 155 columns i dare anyone to beat me:mad: ps. the table is already in 3rd normal form

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #6

              Darn, highest I could find was 84, using this query:

              SELECT
              t.Name AS [Table Name],
              COUNT(*) AS [Column Count]
              FROM sys.Tables AS t
              JOIN sys.Columns AS C
              ON t.Object_ID = c.Object_ID
              GROUP BY
              t.Name
              ORDER BY
              COUNT(*) DESC

              Credit to Pinal Dave for most of the code.

              Thou mewling ill-breeding pignut!

              P 1 Reply Last reply
              0
              • P PIEBALDconsult

                GuyThiebaut wrote:

                required for each row

                GuyThiebaut wrote:

                medical database

                I'm not convinced -- if the table had columns for right and left arm etc., what did you do for patients with missing arms? Leave NULLs? I'd prefer to have different tables for different body parts. :-D

                Mike HankeyM Offline
                Mike HankeyM Offline
                Mike Hankey
                wrote on last edited by
                #7

                and how would you represent a person that is a dick head?

                VS2010/Atmel Studio 6.0 ToDo Manager Extension
                Version 3.0 now available. There is no place like 127.0.0.1

                A G P 3 Replies Last reply
                0
                • Mike HankeyM Mike Hankey

                  and how would you represent a person that is a dick head?

                  VS2010/Atmel Studio 6.0 ToDo Manager Extension
                  Version 3.0 now available. There is no place like 127.0.0.1

                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #8

                  I'd add a record to the [Brendan Fraser] table.

                  Thou mewling ill-breeding pignut!

                  J 1 Reply Last reply
                  0
                  • Mike HankeyM Mike Hankey

                    and how would you represent a person that is a dick head?

                    VS2010/Atmel Studio 6.0 ToDo Manager Extension
                    Version 3.0 now available. There is no place like 127.0.0.1

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

                    :laugh: :laugh: :laugh: +5

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

                    ― Christopher Hitchens

                    1 Reply Last reply
                    0
                    • V Vasily Tserekh

                      I have a table in the application i am developing of 155 columns i dare anyone to beat me:mad: ps. the table is already in 3rd normal form

                      D Offline
                      D Offline
                      dan sh
                      wrote on last edited by
                      #10

                      Assuming you use SQL 2008, you are still 29845 short.

                      "The worst code you'll come across is code you wrote last year.", wizardzz[^]

                      1 Reply Last reply
                      0
                      • A AspDotNetDev

                        I'd add a record to the [Brendan Fraser] table.

                        Thou mewling ill-breeding pignut!

                        J Offline
                        J Offline
                        jeron1
                        wrote on last edited by
                        #11

                        AspDotNetDev wrote:

                        [Brendan Fraser] table.

                        Congratulations! You have just won the 'Came Out of Left Field Reference of the Day' award (COOLFRODA). :-D

                        1 Reply Last reply
                        0
                        • Mike HankeyM Mike Hankey

                          and how would you represent a person that is a dick head?

                          VS2010/Atmel Studio 6.0 ToDo Manager Extension
                          Version 3.0 now available. There is no place like 127.0.0.1

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #12

                          Referential integrity would prevent that.

                          Mike HankeyM 1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            Referential integrity would prevent that.

                            Mike HankeyM Offline
                            Mike HankeyM Offline
                            Mike Hankey
                            wrote on last edited by
                            #13

                            So would birth control!

                            VS2010/Atmel Studio 6.0 ToDo Manager Extension
                            Version 3.0 now available. There is no place like 127.0.0.1

                            P 1 Reply Last reply
                            0
                            • A AspDotNetDev

                              Darn, highest I could find was 84, using this query:

                              SELECT
                              t.Name AS [Table Name],
                              COUNT(*) AS [Column Count]
                              FROM sys.Tables AS t
                              JOIN sys.Columns AS C
                              ON t.Object_ID = c.Object_ID
                              GROUP BY
                              t.Name
                              ORDER BY
                              COUNT(*) DESC

                              Credit to Pinal Dave for most of the code.

                              Thou mewling ill-breeding pignut!

                              P Offline
                              P Offline
                              PIEBALDconsult
                              wrote on last edited by
                              #14

                              SELECT TOP 1 * FROM
                              (
                              SELECT s.Name AS [Schema name]
                              , t.Name AS [Table Name]
                              , COUNT(*) AS [Column Count]
                              FROM sys.Tables AS t
                              JOIN sys.Schemas AS s
                              ON T.schema_id=s.schema_id
                              JOIN sys.Columns AS C
                              ON t.Object_ID = c.Object_ID
                              GROUP BY s.Name,t.Name
                              ) T
                              ORDER BY [Column Count] DESC

                              Shows me 107.

                              1 Reply Last reply
                              0
                              • Mike HankeyM Mike Hankey

                                So would birth control!

                                VS2010/Atmel Studio 6.0 ToDo Manager Extension
                                Version 3.0 now available. There is no place like 127.0.0.1

                                P Offline
                                P Offline
                                PIEBALDconsult
                                wrote on last edited by
                                #15

                                Too late for that.

                                Mike HankeyM L 2 Replies Last reply
                                0
                                • P PIEBALDconsult

                                  Too late for that.

                                  Mike HankeyM Offline
                                  Mike HankeyM Offline
                                  Mike Hankey
                                  wrote on last edited by
                                  #16

                                  I'd recommend a lobotomy, but I'm afraid Mr. Fraiser has already had his!

                                  VS2010/Atmel Studio 6.0 ToDo Manager Extension
                                  Version 3.0 now available. There is no place like 127.0.0.1

                                  1 Reply Last reply
                                  0
                                  • P PIEBALDconsult

                                    Too late for that.

                                    L Offline
                                    L Offline
                                    lewax00
                                    wrote on last edited by
                                    #17

                                    Murder is just late term birth control.

                                    1 Reply Last reply
                                    0
                                    • V Vasily Tserekh

                                      I have a table in the application i am developing of 155 columns i dare anyone to beat me:mad: ps. the table is already in 3rd normal form

                                      E Offline
                                      E Offline
                                      Ennis Ray Lynch Jr
                                      wrote on last edited by
                                      #18

                                      Move it to the fourth normal and get rid of the nulls.

                                      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                                      L 1 Reply Last reply
                                      0
                                      • V Vasily Tserekh

                                        I have a table in the application i am developing of 155 columns i dare anyone to beat me:mad: ps. the table is already in 3rd normal form

                                        J Offline
                                        J Offline
                                        Jeremy Hutchinson
                                        wrote on last edited by
                                        #19

                                        We have a table with 289 columns. It's in our insurance reserves calculating database, and I have no idea what the table actually does, and I don't think I want to know (there are 7 tables with more than 140 columns)

                                        My Blog[^] Chess Tactics for WP7[^]

                                        1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

                                          GuyThiebaut wrote:

                                          required for each row

                                          GuyThiebaut wrote:

                                          medical database

                                          I'm not convinced -- if the table had columns for right and left arm etc., what did you do for patients with missing arms? Leave NULLs? I'd prefer to have different tables for different body parts. :-D

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

                                          Yes there are better ways of representing the data - it all depends on what you are going to do with it. If you are just looking at a simple full table scan then a wide row can be the best approach. The difficulty is that when you design your tables inevitably six months later there will be a better way to store the data based on how you now want to query it. In the end you just do the best you can with the information you have at the time and rely on the database engine to do the optimisation for you later - if things get really slow you can always de-normalise your data...

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

                                          ― Christopher Hitchens

                                          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