?
Solved

FK / PK relationships across databases?

Posted on 2013-01-14
3
Medium Priority
?
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 400 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 66

Accepted Solution

by:
Jim Horn earned 1600 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

765 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