DB: map to another data model - java

I have 2 data models with different amount of tables in MySQL, but both designed for the same purpose.
I need to have mechanism which will migrate data from model #1 to model #2. It can be stored procedure, a set of SQL-scripts, or Java-code. It would be best to create mappings visually (e.g. drag from Table1M1.field1 to Table1M2.field5). Is there any tool for this exists?

MySQL Workbench has a Database Migration module. Check it out.

Related

Data refresh from one oracle db to another oracle db

I want to get some filtered data from one oracle db and refresh tables in other oracle db and this refresh needs to be done frequently. So what are best possible ways to do it?
Please suggest the optimal way to do it.
Using db links or using oracle schedule jobs or write java code.
There are numerous ways to do this, but the most straightforward is to use materialized views with queries that involve dblinks, which you can schedule refreshes for by using dbms_scheduler. There are a lot of docs online to help you. Here's one:
Working with Materialized Views
I don't know Java so I can't comment it.
As far as database is concerned, one option is to create database link between these two databases and a materialized view in one of them which fetches data over the database link from another database.
You can schedule refresh; there are various options. Read documentation to pick the right one for your situation. Have a quick look at Tim Hall's materialized views article; if you find it interesting, search Oracle documentation (related to version you use) for more info.
create a database link between source and target databases and follow any of these native tool options.
Create a materialized view using query that points to source database.
Write a procedure in target site using select queries to read data from source site and update/insert the target tables accordingly.Later schedule those procedures using scheduler jobs.
Use the Golden gate provided if table you chosen should have primary key or unique key.
you can write your own Java or python code which works like PUB and SUB mode to publish the data into target site.

Is Teiid can use VIEW as the RDBMS does?

Teiid is a data virtualization system that allows applications to use data from multiple, heterogenous data stores.
We know SQL in RDBMS has such a feature: produce a view which including columns from different tables.
Does Teiid has the same feature when integrate data from different data source.
For example, there is a flat file data source with a schema (id, book_name), and a rdbms data source with a schema (id, price). Is there any solution to make a integration schema(id, book_name, price) in Teiid?
Teiid has the ability to create views manually using DDL allowing you to bring together columns from different tables/data sources.
For a small example have a look here: http://teiid.blogspot.com/2012/03/dynamic-vdbs-are-back-with-punch.html
Currently I have been doing all views manually on dynamic VDBs, there is also the Teiid Designer (eclipse plugin) that can make the creation of views much easier.
Thanks
Yes, you can combine the data from any number of sources. Yes, your example of flat file and RDBMS is one of the first quick start examples. See https://docs.jboss.org/author/display/teiidexamples/Data+Federation+Example

Join data from 2 Oracle tables located in different database on the same server using JDBC

I have one simple table in one Oracle database that needs to be joined with a group of tables in another Oracle database. They reside on the same server (different ports). I am using JDBC and want to keep it simple. I could connect to both DBs and join the result sets in Java. But I am wondering if there is a better/easier way.
I cannot easily use new tools or frameworks since I work in the rigid corporate environment, so want to know if it can be accomplished with just JDBC.
No way to do it in pure JDBC as far as I am aware, but you could use the oracle databaselink facility. It makes the tables from one database available in another, allowing you to carry out joins etc as if they were in the same database. JDBC will work nicely with tables that are subject to these links.
Setting them up is an administrative function, so you'll need some DBA involvement.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5005.htm
Other than that, if the "one" table isn't too big, you may have to read that to a Map and then peform the join parts of the query in your code ( which is not ideal )
I see two options.
Get the data from two datasources manually and then combine it(which you have already thought about).
Create a db link from one database to other database and create a synonym in your schema for the remote object and directly execute the sql statement with joins from java.

Date versioning and restoring

We are developing a SAAS based application. One of the requirements is to record every change in database tables i.e. create date/time based version of data. Client should be able to revert back to any version of data.
I have almost 30 tables in database, and data insertion frequency is 80,000 records added/updated per day through bulk import. However, client can also use GUI to insert data through forms (other than bulk import).
Before creating any strategy to implement this requirement, I would love have your comments/suggestion on how to implement this.
On a side note, I have reviewed this blog post and found it very good starting point but I still doubt on how to restore past data.
Database snapshot is a promising solution, but as I said earlier that this is a SAAS based application and we are storing multiple clients data in a single database, and snapshot would restore data for other clients as well.
Please suggest any strategy/plan on how to execute this requirement.
If you plan on using JPA/Hibernate to fetch your data, you can give Envers a shot.
Envers is a JBoss open-source project for maintaining versions of Database Entities. You can mark certain columns of the entire table with #Audited annotation to start tracking audit history. It typically stores all the audit data in a table with _AUDIT name. It also provides API to query historical data.
For details please go thru http://www.jboss.org/envers

easy object persistence strategy - hibernate?

I'm doing a Java software-project at my university that mainly is about storing data-sets (management of software tests).
The first thing I thought of was a simple SQL DB, however the necessary DB scheme is not available for now (let's say the project is stupid but there's no choice).
Is a persistency framework like Hibernate able to store data internally (for example in XML) and to convert this XML into decent SQL later?
My intention is to use the additional abstraction layer of a framework like Hibernate to save work, because it might have conversion functions. I know that Hibernate can generate class files from SQL, but I'm not too sure whether it needs a DB at every point during development. Using a XML Scheme for now and converting it into SQL later maybe an idea :)
You can persist XML with hibernate into a relational DB, but you cannot use XML directly as a storage engine. Why not simply store you're data into a relational db from the start - you'll create some schema yourself and you'll adapt it to the actual one when you receive it.
I would recommand using a lightweight DB such as HSQLDB instead.

Categories