My situation is as follows
I have a sql-server running, which holds a few databases.
The physical size of the largest database is about 2 GB, it has 343 tables, 129 views and some stored procs and functions
Now we have started development of a new application, that uses it's own database on that same server, but a few tables should be "shared" by both databases.
In a few months the development of yet another new application will start, and that will also use these few "shared" tables.
What is the best method to do this,
- do I keep the "shared" tables in the original database and let the
other applications (and databases) just use them ? - do I make a copy of the "shared" tables on the other databases, and somehow keep them in sync ?
- do I make another database that holds only the "shared" tables ?
The "shared" tables can off course have foreign keys to other tables, and they can be referenced by other tables in their foreign keys.
This only makes things more complicated
Also our applications/databases are very dynamic, I get to make changes in tables at least 1 or 2 times a month
I would like some advise in this matter
Option 1 looks like the most easy method, but it makes the applications/database not stand-alone. At this time this is not a problem, but I don't know what the future brings off course.
Option 2 seems like a nice solution, but I am afraid that keeping the tables in sync will be not so easy. And off course any changes to one table can be more difficult
Option 3 seems difficult because of all the relations of the tables, would this mean that all tables that are referred must also be in this shared database, even if only one application/database needs them ?
What is the preferred method for doing this ?
What are my options and what are the advantages/disadvantages of each option ?
Is there an option 4 ?
EDIT
After reading the answer and the comment, and discussing it with the development team, we think we are going for option 1 for the following reasons
- The application has to connect with 2 databases, but that is also to the case in option 3.
- FK relations and other referential integrity will not be a problem, as opposed to option 3
- We don't have a problem with "vertical slicing", adding columns to a table specific for one application is not a problem for us
If I am wrong with this, or if there are other things to consider that I have not seen I will welcome all comments and opinions.
EDIT 2
As requested in the comments, all the applications will be able to read and write in the shared tables.
And it is possible that an application can start a transaction, update more than one table including a shared table, and then commit/rollback
EDIT 3
To make things clear and to respond on question in answers/comments.
The idea is to have 2 or 3 application use the same shared tables.
For example, in application_1
I have a table called tblRelation
, which holds customers, loadingplaces, fuell stations, etc...
In application_2
I have a different database, but it needs the exact same data in table tblRelation
So, table tblRelation
is for me a "shared table", I have now 2 applications that can read and write into this table.
Both applications are Corporate wide Enterprise Applications
which handle different actions, have mostly different data, but do share the corporate data, like tblRelation