How to bond N database table with one master-table? How to bond N database table with one master-table? database database

How to bond N database table with one master-table?


I think you are confusing the concepts of "store" and "book".

From you comments and the example data, it appears the problem is in having different sets of attributes for books, not stores. If so, you'll need a structure similar to this:

enter image description here

The symbol: enter image description here denotes inheritance1. The BOOK is the "base class" and BOOK1/BOOK2/BOOK3 are various "subclasses"2. This is a common strategy when entities share a set of attributes or relationships3. For the fuller explanation of this concept, please search for "Subtype Relationships" in the ERwin Methods Guide.

Unfortunately, inheritance is not directly supported by current relational databases, so you'll need to transform this hierarchy into plain tables. There are generally 3 strategies for doing so, as described in these posts:

NOTE: The structure above allows various book types to be mixed inside the same bookstore. Let me know if that's not desirable (i.e. you need exactly one type of books in any given bookstore)...


1 Aka. category, subclassing, subtyping, generalization hierarchy etc.

2 I.e. types of books, depending on which attributes they require.

3 In this case, books of all types are in the many-to-many relationship with stores.


If you had at least two columns which all other tables use it then you could have base table for all books and add more tables for the rest of the data using the id from Base table.

UPDATE:

If you use entity framework to connect to your DB I suggest you to try this:

Create your entities model something like this:

Entities model

then let entity framework generate the database(Update database from Model) for you. Note this uses inheritance(not in database).

Let me know if you have questions.


Suggest data model:
1. Have a master database, which saves master data
2. The dimension tables in master database, transtional replicated to your distributed bookstore database
3. You can choose to use updatable scriscriber or merge replication is also a good choice
4. Each distributed bookstore database still work independently, however master data either merge back by merge replication or updatable subscriber.
5. If you want to make sure master data integrity, you can only read-only subscriber, and use transational replication to distribute master data into distributed database, but in this design, you need to have store proceduces in master database to register your dimension data. Make sure there is no double-hop issue.