Last post Dec 14, 2010 07:50 AM by sarfrazahmed
Dec 13, 2010 11:15 AM|bendahmon|LINK
Hi (sorry if this is in the wrong section)
Is it possible/recommended to have multiple database projects that uses the same database? We're developing a serviced oriented system and we want to separate database projects based on which service their tables belong to.
Let's say I have the following:
- Database with two tables (Users and Companies)
- 2 services UserService and CompanyService
- 1 Database project for the UserService that has scripts for the Users table.
- 1 Database project for the CompanyService that has scripts for the Companies table.
What would you recommend? (I know this isn't an absolute truth)
- 2 DB projects and 2 DBs?
- 2 DB projects and 1 DB?
- 1 DB project and 1 DB?
Dec 13, 2010 02:05 PM|atconway|LINK
What do you mean when you say "Database Project"? Do you mean a VS.NET project representing a wrapper (like a DAL or Repository) via a service? If the answer is "Yes" then 1 database can
easily contain both tables, and you would only really need a single service sitting on top of it. With a 1:1 mentality of services to individual database tables, and in the future if your database grew to 100 tables, then you would have 100 separate
services which would be a pain to manage and maintain.
Dec 14, 2010 05:30 AM|bendahmon|LINK
Hi, in this case I mean a "SQL Server 2008 Database Project" (as you can make using Visual Studio 2010) - The project manages changes on the database.
The point is not to have a 1:1 relation between a service and a table. But rather let each service be "in charge" of its own tables. Not mess with tables that belong to another service etc.
We're having a little discussion whether to let ONE database project be in charge of the whole db or try to make one DB project for each service and the tables involved in that service.
Dec 14, 2010 07:38 AM|bmhc|LINK
I usually have 1 DB but multiple services. But the tables and services its not like 1:1.
For example: you have a DB with 2 tables: Users and Profiles. Now I don't make a seperate service for Profiles because a profile cannot exist without a User so the profiles are handled in the UserService when the User is registered or edited. Adding a user
is just adding a user without profile because a User might exists without a profile so there is a difference between adding and registering.
And the BaseService has a connection to the DB.
Dec 14, 2010 07:50 AM|sarfrazahmed|LINK
i agree wih bmhc and would suggest to have 1 DB , 1 Service containing methods to handle Users / Profiles and 1 Project.
You may need to add more tables in future so dont expect to create seperate DBs.
Simpler is better approach