How do I create foreign Keyrelationship with a table in a different database?
You would need to manage the referential constraint across databases using a Trigger.
Basically you create an insert, update trigger to verify the existence of the Key in the Primary key table. If the key does not exist then revert the insert or update and then handle the exception.
CreateTrigger dbo.MyTableTrigger ON dbo.MyTable, After Insert,UpdateAsBeginIfNOTExists(select PK from OtherDB.dbo.TableName where PK in(Select FK from inserted)BEGIN-- Handle the Referential Error HereENDEND
Edited: Just to clarify. This is not the best approach with enforcing referential integrity. Ideally you would want both tables in the same db but if that is not possible. Then the above is a potential work around for you.