Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sharing data across multiple schemas


Sharing data across multiple schemas

Author
Message
Brian McGee-355525
Brian McGee-355525
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 202
I keep hitting this scenario, and would like to know what people think is the best approach.

I have a main database schema, containing about 1000 tables and 100 dictionary tables (lookup data which is not modified by sql code). I have about 10 other schemas, some of which require access to this lookup data.

The approach I have taken historically is to copy the dictionary tables on the basis that they are static anyway, however invariably they get out of synch. Yes I could add tighter controls to ensure people don't change one without changing another etc, however I am wondering is there a preferred technical solution to sharing dictionary data across multiple databases.

They will not all be on the same server. I had thought about creating a separate database just for the dictionary tables and putting one instance on each server, and using replication to keep them up to date from a 'master', but then I can't create foreign keys!

Ideas?
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3095 Visits: 4639
Post suggests there are two different issues here.

1) "Sharing" a table in between different schemas or the same database.
2) "Sharing" a table in between different databases located in different servers.

In the first case, I can see no compelling reason to duplicate the "shared" table to every single schema. I would just access the main -unique- "shared" table just by fully qualifying it.

In the second case, I would go with replication.

_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Brian McGee-355525
Brian McGee-355525
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 202
Thanks for your response.

Problem is foreign keys. I know I can't create FKs to values in other databases (whether on the same server or not), which is why I'm asking, what would be considered best practice for this scenario?

Replication will only help in so far as I can ensure the lookup data is the same on all servers, but.......I lose the ability to apply foreign keys.

Example:

Server1 : MainDB, two smaller DBs. All require same lookup data
Server2 : (Different instance of) MainDB, three smaller DBs. All require same lookup data as above

Currently the lookup data is in the "MainDB" schema. Unless I copy it to the other schema I can't apply foreign keys.

So what do other people do in these situations?

Brian
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3095 Visits: 4639
Question would be... why you want to have FKs on those replicated tables pointing to a different server? Parent-Child relationships are already validated at the source ;-) e.g. your "master" database.

Replication ensures data will be the same.

_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Brian McGee-355525
Brian McGee-355525
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 202
I can see I haven't explained it well enough :-)

Database A, master schema, has dictionary tables such as 'ApplicationName' and 'CustomerType'.
Databases B, C and D are entirely different schemas, however also contain applications and customers of types which need to be validated against a master list.

If I create the 'ApplicationName' table in both databases, the data can get out of synch. I *do* need the tables in each of the A, B, C and D schemas to be validated against these master lists, and can't create FKs if 'ApplicationName' sits outside of these in its own schema, *or* if 'ApplicationName' exists in just one of the schemas.

Do you see?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search