Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
Hi Sergey Alexandrovich

I think i am not able to explain. let me put it in this way


i have a financial application developed in c#.net and MSSQL server. now suppose my database file name is dbfa2012.mdf. ihe client uses this database for year 2012 and after one year i make a fresh blank database dbfa2013.mdf for year 2013. so i want to have a interface where the client can select database dbfa2012 or dbfa2013 of his choice and work

thanks in advance

Pradeep
Posted
Updated 4-Aug-13 9:13am
v2
Comments
Zoltán Zörgő 4-Aug-13 15:44pm    
Why are you addressing yourself to SA? Are you not interested in other people's opinion?
PRADEaZX 5-Aug-13 21:24pm    
its not like that. you will understand if you read SA;s comment

Bad, really bad idea. Even if you don't need any integrity now, in future you may run into problem. Don't work with separate databases. Just don't.

—SA
 
Share this answer
 
Comments
MuhammadUSman1 3-Aug-13 1:11am    
I think Best suggestion.
—SA
Sergey Alexandrovich Kryukov 3-Aug-13 1:15am    
Thank you, Muhammad.
—SA
Zoltán Zörgő 4-Aug-13 15:43pm    
I would agree in general, but I since we speak about SQL Server - having specific mechanisms under the hood - I have to disagree. See my answer.
Sergey Alexandrovich Kryukov 4-Aug-13 17:16pm    
May I ask you what difference can it make, exactly?
—SA
Zoltán Zörgő 5-Aug-13 14:52pm    
Of course. But let me highlight one single aspect: financial year. A regular business activity is highly bound to the financial year. For the sake of simplicity let us assume, that in year 2013 the company will want to access the 2013 year's data in 90% of the cases, the 2012 years's data in 7% of the cases, and 2% the 2011 year, and only 1% the years before 2011. But you have to keep 10 years of data as archive because of the regulation. Why keeping all the data of the previous years in the database? Of course, you can export it in some format, and import if you need it, or keep it and use the selection to see only what you need. Yes, even SQL 2005 could deal with quite large databases, so theoretically, should not be any problem to have terabytes of data. But as it grows, it will be harder to maintain, even harder to fulfill regulatory requirements. And a financial year is a closed something. It is better to keep it as it is, without interfering with other years's data. So, if you can take your 2012 year data as a closed entity and put it on a DVD (or anything else), and than simply attach it if you need it, you gain a lot.
Of course, there are drawbacks one have to deal with: like what if you need to query several years? Of course, this can be also handled.
But my point is: you can choose to have a single database, but if you like, you can, you may use several databases for the one application. And SQL Server will support you in this, even better it's architecture is made to support such scenarios. The instance is made to be allocated to an application, so if you can make use of this, why shouldn't you? It is not that bad as you pointed out.
But I wouldn't do this with across SQL Server instances or with MySQL for example, even if both are also supported: juts because it is out of the conceptual scope of the respective RDBMS.
Actually the idea itself is not that bad - but depends on the application. Ever wondered what is the model database is all about? Well, Microsoft is using an unique view about the database server. Many RDBMS use the database as top level concept related to an application. Microsoft has an ever higher level: the instance. An instance of an SQL Server is intended to be dedicated to an application. The model database[^] is the template for newly created databases. So practically, if you create a good template and dedicate the instance to the application, you can follow your current concept, and simply use SMO to enumerate databases[^].
But I have to emphasize, that this is a very special way to do it, based on Microsoft's own vision. In SQL server it is nothing bad in distributing your data between databases (catalogs) of the same server instance, they work transparently. It is better using this approach than allowing some tables to grow beyond a usability limits - even indexing has it's limitations.
If you take this path, I suggest you create a separate database for the data that is not year-related, like partner data and so on.

An other approach, you can use to partition your year related tables, take a look here: http://databases.about.com/od/sqlserver/a/partitioning.htm[^].

Choosing the best approach necessitates deeper knowledge about the application architecture, data model and business logic.
 
Share this answer
 
Comments
PRADEaZX 5-Aug-13 21:32pm    
thanks, I will try to implement in my project and see how much i am able to do it
Zoltán Zörgő 6-Aug-13 6:35am    
Ok, go for it! :)
 
Share this answer
 
Comments
PRADEaZX 3-Aug-13 0:24am    
Thanks Code-hunt
will check and get back
[no name] 3-Aug-13 0:25am    
Sure..and if it helps then accept the answer so that it will be helpful for others also..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900