views:

58

answers:

3

If you had two databases, that had two tables between them that would normally implement a one to one (or many to many) constraint but cannot since they are separate databases, how would you validate this relationship in an application or test?

Is there a simple way to do this? For example, a tool or technique that can, given a constraint type, tables and fields, does the validation.

I imagine that this isn't the first time this come up so I'm hoping people can share their solution.

Thanks.

A: 

If you can set up linked servers you could achieve this effect using a trigger, but actually setting a constraint is as far as i know, impossible.

Paul Creasey
Yes, I am not trying to setup a constraint. I assumed this was impossible/impractical. This is why I am looking to do this programmatically.
Brandon
Are you able to set up a linked server?
Paul Creasey
I can look into this approach, I was not aware of this. Thanks.
Brandon
A: 

Your question is unclear, what programming language are you planning on using to accomplish the task?

"If you had two databases, that had two tables between them that would normally implement a one to one (or many to many) constraint...."

alexy13
A: 

It sounds to me as though you're talking about referential integrity constraints. Hibernate Shards adds horizontal partitioning support to Hibernate so that you can have a single Hibernate model which is spread over multiple databases. That said, I don't know if the project is still under active development, and it may complicate your life in other ways. I'm not sure if it's compatible with JPA, for example.

Paul Morie