Solved

FK / PK relationships across databases?

Posted on 2013-01-14
3
326 Views
Last Modified: 2013-01-15
I have an MS SQL 2008 R2 instance. There are 3 databases; I will say db_1, db_2 and db_3. I want db_2 to hold all the common information like users, email addresses, and some other metadata, then the other 2 db's will be for 2 separate front end transactional applications. Is there a way to enforce PK / FK constraints across databases in the same MS SQL server instance?
0
Comment
Question by:sqlagent007
3 Comments
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 100 total points
ID: 38777096
hi
i think it would be very difficult because your tables are in different databases

i suggest either to put all your tables in one database and do the PK/FK

or keep the design as it is and control every thing from you Code( to do insert / update /delete)
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 400 total points
ID: 38778098
>Is there a way to enforce PK / FK constraints across databases
No.  relationships are within a database only.

The closest you can get, and even this is somewhat of a house of cards, would be to write trigger code in one_db.one_table, testing to see if the ID is unique compared to other_db.other_tables, and if not either denying the insert or changing the ID.
0
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 38778590
Thanks experts!!!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to count occurrences of each item in an array.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now