views:

235

answers:

4

Hi guys, I have a bit of an issue, and to be honest I don't think there's an answer, but I'll give it a try anyway.

So I have two databases [A]->Company and [B]->Product. Both databases have a Country table which is then linked to other tables in each individual database. The problem is that the data between the two Country tables is a complete duplicate. So, I essentially have to duplicate some of the relationships in each database, and maintenance on top of that is just difficult...

So, I'm curious is there a way to create a cross-database relationship between tables so I can have only one set of Country+Helper tables that govern both databases?

Thanks in advance!

+1  A: 

Well you might want to think about having one transaction database, and two databases for data persistence? Lots of work, but it seems like the best viable option -- every transaction in the write would trigger a write to each of the "read" databases? I'm not sure I'm understanding the question completely, maybe?

Plan B
I was thinking something similar. I was thinking about a third database [C] which will be read only and [A] and [B] would have "fake" relationships still based on the primary keys in [C] I would just have to do the linking in code. Not pretty, but it kind of reduces the complexity of the two databases.
Alex
Hmm that's one way. If you do a bit of research on sharding concepts and RAID storage, you might get some ideas. I think you want to reduce the complexity, transaction wise, to one DB, then distribute the results to each storage DB. Something along those lines.
Plan B
A: 

You can't do this with foreign key contraints. You could enforce the relationship it with triggers, but it's a bit of a pain.

Ray
+2  A: 

You can't have physical relationships that span multiple databases, to enforce FK constraints.

You can still have the core lookup/helper tables in one database, but you'd just have to have an inferred FK constraint on to it from the tables in the other databases - a logical assumption, rather than something physically constrained.

AdaTheDev
A: 

Keep in 1st database table & create a view from this table in 2nd database

Roman Spivak