Wednesday, March 28, 2012

Relationships between tables in different SQL databases

There are several databases (currently in Access) that are being moved to SQL Server. Would prefer keeping those databases separate in SQL Server. How do you do something similar to Access's "link" capabilities and relate tables in different physical databases? For example, relate the authors of a document in a document database to persons in a people database where AuthorID in Docs.DocAuthors.AuthorID is related to People.Persons.PersonID

It is normal in SQL Server to combine all of the data for an application into a single database.

SQL Server does not have the size limitations of Access.

You can keep security separate (if that is your need) with the use of Schemas. Refer to Books Online, Topics:

Schema

User-Schema Separation

|||

Found out the SQL doesn't support cross-database foreign keys. Using schemas to separate related tables requires extra typing when programming and requires tedious program updates if a table changes schema. Will stick to keeping all tables in one database and under the default "dbo" schema.

Not sure if SQL has a similar "dbLink" API similar to Oracle's "dbLink" to SQL. Still looking for equivalent "dbLink" in SQL.

|||Refer to Books Online, Topic: 'Linked Servers'

No comments:

Post a Comment