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. Update Database for C# application

Update Database for C# application

Scheduled Pinned Locked Moved Database
databasequestioncsharptoolsperformance
6 Posts 3 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.
  • P Offline
    P Offline
    PDTUM
    wrote on last edited by
    #1

    So...it seemed like a good idea at the time. I have a C# application that is distributed among multiple users (about a dozen). I set each user up with their own database (MS SQL 2005) so there is no interaction between users and it works great. Now, I am making a change to the program which requires a change to the database. In the past, with just a few users, I simply went into each database and altered the tables one at a time ... takes a few minutes for each one. But as the number of users grow and I keep adding features to the application more frequently ... well, you can see where this is going. My question is; what type of command can I use to alter the databases (a script of some kind?) to add or remove columns from tables, add tables, etc. to make it so that I can alter multiple identical database structures at the same time while maintaining the data in them. Although I have been making databases for my applications for about 15 years, this is an area that I have never had to deal with; something I would assume would normally be the job of a dedicated DBA. If applications end up being sold on a larger scale (and it is heading that way), then I would hire such a person immediately. I considered having everyone in a single large database at the start and simply use proper queries to pull the data, but I decided that the sheer size and loss of performance would not make it as nice as it is, especially if I were to end up with several hundred users. There are about 30 tables in the database. I never really understood the limits and capabilities of these databases; only to say I don't really trust them to do the job when they get too large(not very scientific; more of a gut feeling). Am I way underestimating the ability of the database? Until then, can you give me a lead in on how to do this? I love it here at Code Project and I Thank You for your time....Pat

    D N 2 Replies Last reply
    0
    • P PDTUM

      So...it seemed like a good idea at the time. I have a C# application that is distributed among multiple users (about a dozen). I set each user up with their own database (MS SQL 2005) so there is no interaction between users and it works great. Now, I am making a change to the program which requires a change to the database. In the past, with just a few users, I simply went into each database and altered the tables one at a time ... takes a few minutes for each one. But as the number of users grow and I keep adding features to the application more frequently ... well, you can see where this is going. My question is; what type of command can I use to alter the databases (a script of some kind?) to add or remove columns from tables, add tables, etc. to make it so that I can alter multiple identical database structures at the same time while maintaining the data in them. Although I have been making databases for my applications for about 15 years, this is an area that I have never had to deal with; something I would assume would normally be the job of a dedicated DBA. If applications end up being sold on a larger scale (and it is heading that way), then I would hire such a person immediately. I considered having everyone in a single large database at the start and simply use proper queries to pull the data, but I decided that the sheer size and loss of performance would not make it as nice as it is, especially if I were to end up with several hundred users. There are about 30 tables in the database. I never really understood the limits and capabilities of these databases; only to say I don't really trust them to do the job when they get too large(not very scientific; more of a gut feeling). Am I way underestimating the ability of the database? Until then, can you give me a lead in on how to do this? I love it here at Code Project and I Thank You for your time....Pat

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Whew, lots of questions here. Let me suggest one item. You should create a script that would methodically alter the necessary tables, columns etc and use that script to update your various clients. Here is a reference to the ALTER TABLE command ... http://msdn.microsoft.com/en-us/library/ms190273.aspx[^] There are tools out there which compare 2 schemas and generate scripts which make the necessary changes. The idea is that you point it at database1 ver 1.0 and at database2 ver 2.0 and the tool will detect that there are new tables, new columns, etc.

      P 1 Reply Last reply
      0
      • D David Mujica

        Whew, lots of questions here. Let me suggest one item. You should create a script that would methodically alter the necessary tables, columns etc and use that script to update your various clients. Here is a reference to the ALTER TABLE command ... http://msdn.microsoft.com/en-us/library/ms190273.aspx[^] There are tools out there which compare 2 schemas and generate scripts which make the necessary changes. The idea is that you point it at database1 ver 1.0 and at database2 ver 2.0 and the tool will detect that there are new tables, new columns, etc.

        P Offline
        P Offline
        PDTUM
        wrote on last edited by
        #3

        Thank you David. I appreciate your suggestion and I have found a little better link (solution) than Microsoft's to describe the Alter command's use. I will practice with it on a sample database and then include that script as part of the program update. If you get this and you specifically know of some better comparative software for database modification, please let me know, and THANKS again.... ps; sorry about all the questions. I am methodical and just want to get it right the first time if I can. I appreciate your response! Pat

        1 Reply Last reply
        0
        • P PDTUM

          So...it seemed like a good idea at the time. I have a C# application that is distributed among multiple users (about a dozen). I set each user up with their own database (MS SQL 2005) so there is no interaction between users and it works great. Now, I am making a change to the program which requires a change to the database. In the past, with just a few users, I simply went into each database and altered the tables one at a time ... takes a few minutes for each one. But as the number of users grow and I keep adding features to the application more frequently ... well, you can see where this is going. My question is; what type of command can I use to alter the databases (a script of some kind?) to add or remove columns from tables, add tables, etc. to make it so that I can alter multiple identical database structures at the same time while maintaining the data in them. Although I have been making databases for my applications for about 15 years, this is an area that I have never had to deal with; something I would assume would normally be the job of a dedicated DBA. If applications end up being sold on a larger scale (and it is heading that way), then I would hire such a person immediately. I considered having everyone in a single large database at the start and simply use proper queries to pull the data, but I decided that the sheer size and loss of performance would not make it as nice as it is, especially if I were to end up with several hundred users. There are about 30 tables in the database. I never really understood the limits and capabilities of these databases; only to say I don't really trust them to do the job when they get too large(not very scientific; more of a gut feeling). Am I way underestimating the ability of the database? Until then, can you give me a lead in on how to do this? I love it here at Code Project and I Thank You for your time....Pat

          N Offline
          N Offline
          Nicholas Swandel
          wrote on last edited by
          #4

          I am wondering about your concerns about consolidating to a single large database. What are the largest row counts for your 30 tables for the biggest user? Database consolidation would seem to be a very attractive option, unless the numbers are extremely large. I suspect your may actually be losing performance by having seperate databases. A DB instance has a considerable base overhead and you are decreasing the available resources by that amount for each user you have. Further, the simplifacation in administration would be considerable.

          Regards Nicholas Swandel

          P 1 Reply Last reply
          0
          • N Nicholas Swandel

            I am wondering about your concerns about consolidating to a single large database. What are the largest row counts for your 30 tables for the biggest user? Database consolidation would seem to be a very attractive option, unless the numbers are extremely large. I suspect your may actually be losing performance by having seperate databases. A DB instance has a considerable base overhead and you are decreasing the available resources by that amount for each user you have. Further, the simplifacation in administration would be considerable.

            Regards Nicholas Swandel

            P Offline
            P Offline
            PDTUM
            wrote on last edited by
            #5

            Thank you for your thoughts Nicholas. Truthfully, I am confused due to my lack of experience with "big" databases. Big is a relative term. What is Big? Perhaps some numbers might help. Lets say that there is a table called 'Orders' and it has 30 columns. Now lets say that it creates about 10 new rows every day per client. It must be able to retrieve 2 years worth of data in this table before it can be purged, or about 500 days. So that would be 5000 rows per client. Now, if it was a single database being shared by potentially 1000 users, that would make 5 million rows with 30 columns each for this table. Assuming that about 8 of the tables have this same amount of data, and the others are much smaller, the question is "is this big"? The problem is that I do not know. It seems big to me, but then again, I never understood how a major search engine can look through billions of entries in a matter of seconds either. To your statement that separate databases decrease performance, I would disagree with that in its entirety. On the other hand, I totally agree that Administration, which is what triggered the request for information in the first place, is definitely the issue of concern for me with individual databases. I suppose I could write an 'update' script to modify the database each time I update the program (a possible solution). I am at the point that I must go one way or the other. You raise some excellent points. Looking it over, perhaps a Hybrid choice is possible. Nothing says I cannot have 10 databases instead of 1000 which would limit the total users to 100 and decrease the data storage by 90 percent. Perhaps? The question is...Is that Enough? At how many users do I stop and make another database...10, 50, 100? I will keep researching and considering expertise from developers like yourself, for which I am grateful. If you have any followup thoughts, or can shed some light for me on the numbers game, please feel free to write me either here or privately. I appreciate your time and expertise. Thank you again. Best Regards, Pat

            N 1 Reply Last reply
            0
            • P PDTUM

              Thank you for your thoughts Nicholas. Truthfully, I am confused due to my lack of experience with "big" databases. Big is a relative term. What is Big? Perhaps some numbers might help. Lets say that there is a table called 'Orders' and it has 30 columns. Now lets say that it creates about 10 new rows every day per client. It must be able to retrieve 2 years worth of data in this table before it can be purged, or about 500 days. So that would be 5000 rows per client. Now, if it was a single database being shared by potentially 1000 users, that would make 5 million rows with 30 columns each for this table. Assuming that about 8 of the tables have this same amount of data, and the others are much smaller, the question is "is this big"? The problem is that I do not know. It seems big to me, but then again, I never understood how a major search engine can look through billions of entries in a matter of seconds either. To your statement that separate databases decrease performance, I would disagree with that in its entirety. On the other hand, I totally agree that Administration, which is what triggered the request for information in the first place, is definitely the issue of concern for me with individual databases. I suppose I could write an 'update' script to modify the database each time I update the program (a possible solution). I am at the point that I must go one way or the other. You raise some excellent points. Looking it over, perhaps a Hybrid choice is possible. Nothing says I cannot have 10 databases instead of 1000 which would limit the total users to 100 and decrease the data storage by 90 percent. Perhaps? The question is...Is that Enough? At how many users do I stop and make another database...10, 50, 100? I will keep researching and considering expertise from developers like yourself, for which I am grateful. If you have any followup thoughts, or can shed some light for me on the numbers game, please feel free to write me either here or privately. I appreciate your time and expertise. Thank you again. Best Regards, Pat

              N Offline
              N Offline
              Nicholas Swandel
              wrote on last edited by
              #6

              5 million is not very big. Typically tables are indexed to make retrieval quick. Further there are other DB features such as partitioning that would allow the table to appear as one large table but the DB would actually store the table and its indexes in seperate partitions based on some attrubute, likely, in your case, a user id or more likely a set of user ids. Retreival would then only look at the index and table partitions for the individual user or set of users. Keep an open mind, I think your strong view that separate databases increase performance is miss placed. We have done a exercise of consolidating 50+ databases each with 30,000+ tables and 10 of millions of rows in some tables. Same harwdare and the performance gain was about 3 times, administration effort cut 3 fold. The memory and CPU requirements just to start a single DB is considerable, consolidating allows these resource to be better utilized and boosts performance. There is also the idea that each user could be contained in a schema within a single DB, this is a half measure though as will you would gain performance, administration would still be high. I would encourage you to try a proof of concept with a single table on 10-30 DBs shut down those DBS and compare it to the combined verion of the table on one DB with all the resources from the 10-30 DBS allocated to single DB. The single DB is typically dramatically faster.

              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