Sharing data across multiple schemas

  • 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 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.
  • 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

  • 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.
  • 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?

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply