Proper way to develop database applications
Hi guys
Recently i had a discussion with someone about the proper way to develop a database driven (SQL Server) application.
In his opinion i should design also the database inside the application.
At this moment i design the database in SQL Managaement tool and use a custom class to connect to this database (or the one of the client) in my application.
I could do this also in VS but i'll lose immediatly the flexibility of this approach.
What are the cons and pro's of using the VS database designer inside my IDE?
Thanxxx
Re: Proper way to develop database applications
You have two choices with SQL Server. You can either connect to a database that is already attached to the server or you can attach a database when you connect. The second option is only available with SQL Server Express and the database must be added to your VS project and built in VS.
If you go with the first option then it makes no difference whether you use VS to build the database or Management Studio. The end result is exactly the same. Management Studio does have some extra features as it was built for SQL Server specifically but, if you don't use them anyway, you won't miss them.
Re: Proper way to develop database applications
so, if i understand it correctly, it isn't nessecary to develop the database along with the application in the IDE. I could simply split them in 2 projects.
Because what i don't understand is the next.
If i do so and afterwards compile and distribute the application, i still have to install and attach the database manually or will the currently attached database be updated (in case a add a table or row)
Re: Proper way to develop database applications
Like I said, you can either connect to an attached database or attach the database when you connect.
In the former case the application assumes that the database is already attached to the server, so you must either attach an existing database or create a new database before running the application. In that case you would usually do as you are already: build the database in Management Studio. You would then either attach a backup of that database as one of the steps of deploying your app or else build a new database on the server by executing SQL statements.
In the latter case you would add the database to your VS project as an item, just like a form or a class, and then build it in VS. The database, i.e. the MDF file, would be distributed with your app and probably sit in the same folder as your EXE. Each time you connect the database will be temporarily attached to the server and it will be detached again when the connection is closed.
Neither approach is more right or wrong than the other. Each has its advantages and disadvantages. Attaching a database to SQL Server Express on demand is overall more convenient but it does have limitations. Mainly, it's really only suitable for local applications, i.e. apps where there is only one instance accessing a server on the local machine. For multi-user and network apps you'd normally keep the database attached permanently.
Re: Proper way to develop database applications
Ok thanxx jmcilhinney
Very clear.
was already wondering if did something wrong.
;)