Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sharing data across multiple schemas Expand / Collapse
Author
Message
Posted Thursday, October 1, 2009 2:32 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, July 20, 2014 6:13 PM
Points: 58, Visits: 196
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?
Post #796188
Posted Thursday, October 1, 2009 9:04 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, January 28, 2014 8:15 AM
Points: 3,068, Visits: 4,639
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.
Post #796403
Posted Thursday, October 1, 2009 9:12 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, July 20, 2014 6:13 PM
Points: 58, Visits: 196
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
Post #796411
Posted Thursday, October 1, 2009 1:13 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, January 28, 2014 8:15 AM
Points: 3,068, Visits: 4,639
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.
Post #796592
Posted Monday, October 5, 2009 3:07 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, July 20, 2014 6:13 PM
Points: 58, Visits: 196
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?
Post #797724
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse