Migrate/Sync Data between tables of different Schemas - sql

thanks for sparing some time by looking at my question. I am not sure if this is practical and already answered but i don't have words to search for so i will explain the problem here:
We have 2 Databases, "CRM" and "Reporting". "CRM" database is the primary database where we store all our data.
In "Reporting" db we have created 5 views that fetch data from "CRM" db tables at run-time and done some reporting on them. The separate database is because we are not allowed to created "Store Procedure/Views" in "CRM" db.
Now when we run our reports, based on Views that are in "Reporting" db they are very slow because of complex joins in the views and other computing logics. We have done the required indexing and things but that doesn't help much.
What i want to do is fetch data from "CRM" db using "Views" in the "Reporting" db and store them in some tables in "Reporting" and do a simple "select *from table" in reports. The tables will have the exact same structure as views in "Reporting" db.
Questions: I am not sure how the data updates/creates will be synced between "CRM" and "Reporting" tables provided that data will be fetch through views to keep the calculated/report ready data ?

Related

Power BI Direct query mode - handle multiple tables

I have a azure sql db where all tables sit - fact, dimension other lookups. Have a requirement to pull(3 tables) a fact table, a dimension and another lookup table(not part of star schema) via direct query and be part of data model within Power BI.
Direct query doesn't allow more than one table to query against(from a single source).
Any thoughts/suggestions?
Sorry.. thanks to Jon's response, it triggered me to look further and I have found that for each table(from same source) I have to go through 'get data' process.
Initially, I thought via one 'get data' process I could multi select tables, but, obviously not.
All ok here now.
I tried with mysql db, I able to select multiple tables and load once to power bi.
New Source -> Database -> Mysql Database -> Add host and password ----> then you retrieve window with table list --> it views tables, views , procedures etc....

What is schema and database?

What is the difference between schema and database? I have no knowledge other than running basic commands in sql such as select, update, insert and delete.
A Database is a collection of organized data, while database schema describes the structure and organization of data in a database system. The database holds the records, fields and cells of data. The database schema describes how these fields and cells are structured and organized and what types of relationships are mapped between these entities. Understandably, the schema of a database keeps constant once created, while the actual data in the database tables may change all the time.

QlikView diagram with relations between DB tables and QV objects

May be anybody know.
Can I see via QlikView (something same to TableViewer) diagram with relations between my table in Db and QV objects (I mean tables which created in QlikView from qvd files).
You can display the table structure (Ctrl+T) to see how your tables are connected.
HTH

Updating/Inserting tables in one database from another database

How can I sync two databases and do a manual refresh on the entities on either of the database whenever I want?
Let's say I have two databases DB1(prod) and DB2(dev). I want to update/insert only a few tables from prod DB to dev DB. How could I achieve this? Is this possible instead of DBlink since I do not have privileges to create a database link?
If you only want to do a manual refresh set up an import/export/datapump script to copy the data across if there is not too much data involved. If there is a large amount of data you could write some pl/sql as described above to only move the new/changed rows. This will be easier if your data has fields such as created/updated_on

How can i combine more then one database's data in one database with same schema

I have a 5 database with same schema, i want to copy all data in one database with same schema
or how can i copy data from *.mdf files in database.
i am using sql server 2005
Copy Database with T-SQL:
sqlauthority
http://blog.sqlauthority.com/2009/07/29/sql-server-2008-copy-database-with-data-generate-t-sql-for-inserting-data-from-one-table-to-another-table/
Copy Database with Wizard:
kodyaz
http://www.kodyaz.com/sql-server-tools/sql-server-copy-database-wizard.aspx
I'd suggest taking a look at Red Gate SQL Data Compare. That will enable you to merge the data between the two databases and directly control which one wins in any given situation.
As mentioned above you need to deal with the Primary Keys as well...
One way to deal with this to add a "Database ID" to all the tables in the single central version. The central PKs become the PK from the source table, plus the "Database ID". This way you have unique PKs in the central version AND you can tell which database the row came from. This is what sql-hub does - there is a free licence which will let you do this as a one-off task - or you could do the inserts for each database and table in SQL.