How to migrate data from one product to another without revealing database structure? - data-migration

What is best way to best way to migrate data from one product to another if both software companies refuse to reveal the database structure to one another?

Define some database structure capable of holding all the relevant information (it doesn't need to be optimized in any way), have the first company dump their data into that and the second one import it.

dump the data to a csv and hand it to the other company. A good DBA can take the data and write a sufficient import script that maps them to the correct datatypes on the other end.

morse code? smoke signals? braille?
really, it sounds like an untenable situation between two parties that have no confidence in once another and sounds poisonous.

Holy smoke. Sounds like great fun of yours ;-).
Just some ideas:
If you have access to the database... for a good dba the migration should be no problem at all.
Another way would be that one company creates views to hide the underlaying datastructures and the other company can import those views.
Otherwise just let them dump the data into flat files and import those files.

Related

Best way to import data using Axon Framwork

What is the best way to import an excel file (or do mass insert) containing entities using the Axon Framework ?
Should we use a command with the excel file as a byte array, then parse the file in the Aggregate and send them each line as an event ? or create an event the list of entities (but then how to update aggregates) ? or parse the excel file outside of the aggregate and then create command of each row ?
Thanks for help.
Technically speaking, you have two options (each with many variations):
Parse the file on the client-side and issue a command per record
Send one command with the entire content (the file itself or the content converted to another format). The command handler (aggregate or not) then iterates over the records and performs the required action per each.
Which one you choose and how exactly do you implement it depends on a lot of factors, such as:
whether or not the data is about "entities" that are part of the same aggregate or not
the size of the data (both in bytes and number of records)
the performance and security requirements and constraints
what information needs to be stored (namely, should the system "remember" there was a "mass insert")
are the aggregates event-sourced or state-stored
...
As you can see, there are way too many possibilities for anyone to be able to give you a generic "best way".
That said, it is a very interesting question that can spark some architectural discussions. Unfortunately, StackOverflow is not the right place to have those (see What topics can I ask about here? and What types of questions should I avoid asking?).
If you would like to discuss those options in more detail I suggest posting the question on AxonIQ's Discuss platform.
it pretty much depends on what kind of Event is valuable for your business.
But in general, parsing the file outside of the Aggregate (this is not what the Aggregate is used for) and firing multiple commands (one for each line) would be my choice.
In that case, you will have an Event on your EventStore for each line which will make it way more explicity about what happened. Also, important to note that in this case, your Events will be granular and not that big, which usually I see as a code smell =)
KR,

full database table update

I currently have a REST endpoint with basic CRUD operations for a sqlite database.
But my application updates whole tables at a time (with a "save" button)
My current idea/solution is to query the data first, compare the data, and update only the "rows" that changed.
The solution is a bit complex because there are several different types of changes that can be done:
Add row
Remove row
Row content changed (similar to content moving up or down)
Is there a simpler solution?
The most simplest solution is a bit dirty. (Delete table, create table and add each row back)
The solution is a bit complex because there are several different types of changes that can be done:
Add row
Remove row
Row content changed (similar to content moving up or down)
Is there a simpler solution?
The simple answer is
Yes, you are correct.
That is exactly how you do it.
There is literally no easy way to do this.
Be aware that, for example, Firebase entirely exists to do this.
Firebase is worth billions, is far from perfect, and was created by the smartest minds around. It literally exists to do exactly what you ask.
Again there is literally no easy solution to what you ask!
Some general reading:
One of the handful of decent articles on this:
https://www.objc.io/issues/10-syncing-data/data-synchronization/
Secondly you will want to familiarize yourself with Firebase, since, a normal part of computing now is either using baas sync solutions (eg Firebase, usually some noSql solution), or indeed doing it by hand.
http://firebase.google.com/docs/ios/setup/
(I don't especially recommend Firebase, but you have to know how to use it in as much as you have to know how to do regex and you have to know how to write sql calls.)
Finally you can't make realistic iOS apps without Core Data,
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreData/index.html
By no means does core data solve the problem you describe, but, realistically you will use it while you solve the problem conceptually.
You may enjoy realm,
https://realm.io
which again is - precisely - a solution to the problem you describe. (Which is basically the basic problem in typical modern app development.) As with FBase, even if you don't like it or decide not to go with it on a particular project, one needs to be familiar with it.

Access MDB database. Linux: how to get a very odd pattern from the DB?

I'm in a VERY difficult problem.
I have a Microsoft Access Data Base, but it was made in the most chaotic way possible. The DB has like 150+ tables, Only uses like 50% of the tables. The relations are almost random. But, somehow, it delivers some information.
I need to get a particular component of the DB, but is so tangled that I can not manage to get into the table that creates that value. I revised every table, one by one, and found nothing.
I used mdbtools for Linux to try to inspect with more details the DB. But unfortunately has not been developed in years, and it closes every time. Maybe because the DB is "big" ? -700 mg-
I'm wondering: is there a way to see all the relations the arrives to the particular value I'm looking? Or to decompile the DB? I have no idea in which language it was made. I'm suspecting that it was made in Visual, just because is rather crappy.
Well, waiting for some help.
I would suggest using (still) MS Access for this. But, if relationships look messy on the diagram, you can query one of the system tables (MSysRelationships) directly to get ALL the relationships you need (e.g. for particular table etc.):
To unhide system tables in early versions of Access (97-2003), follow the instructions here:
For Access 2007, do the following:

Linking Excel and Access

I run a sports program where i have a master roll of who is in which class in excel. I want to link this to a database in access that stores the other information about each athlete, e.g. address, parents name, school, medical details. I want to be able to add names to class in the excel speadsheet and have this automatically generate a record for that person in access. There also needs to be some failsafe for athletes that are in multiple classes. I was also doing class roles as pivot tables out of the access database so i need to code for classes and also have this allow for athletes in multiple classes/disciplines.
It is easy enough to update an Access table from Excel via ADO, after that it is very much about your tables and indexes. If you are not familiar with relational databases, you might like to read http://r937.com/relational.html. That being said, it would be a lot easier to work in Access and output to Excel when necessary.
I agree I think this is a classic case of trying to get excel to do something its not best for. If you try to create some kind of hybrid system with excel pushing data into access then it will end in tears at some point.
The best thing in this case would be to port the whole thing to some kind of database. If the number of uses and the usage falls into the range for access/jet then that would be a great choice. If more users/higher usage is going to be needed then maybe look to SQL express to hold the data and access as a front end.
There was a thread a few days ago about someone being sick when maintaining an access DB, he wanted to rewrite it in .net. The point of that thread boiled down to using the correct tool for the correct job. No one can blankly say “Access sucks, everything should be in SQL server/.net” because if used in the correct way and for the correct projects access is a great tool.
So to bring it back to this thread it looks like you have “outgrown” excel and should be looking at some kind of database with access being a strong candidate
If you want to display the data in Excel (so you can do sorts, filters, etc.) then you could store the data in Access as has been suggested, then instead of exporting a report every time you want to use it, link your Excel file to Access using a Database Query.
In Excel 2003 go to Data->Import External Data->New Database Query and create a new data source to your Access mdb.
That way your data is stored in a much better way, whilst still having the Excel viewability that everyone(?) loves.

Alternative Data Access pattern to Repository

I have certain objects in my domain which are not aggregate roots/entities, yet I still need to retrieve them from a database. I don't want to confuse things by creating repositories for these things. So, what are alternative data access patterns? Would you simply create a DAO for them, while still of course separating the interface?
Edit:
Some more detail on what I'm doing. I need to create a code. This code has certain rules as to its format. One of the rules is that the final character must be a unique number incremented by one from the last code generated. For example:
ABCD1
ABCD2
ABCD3
So, I'm keeping a table with one row, one column to store the number in question. Now, I don't want to consider this number an entity and create a repository for it - that's overkill. I just need a way of retrieving the number, adding 1 to it, and saving it. I know there are myriad ways I could do it, but I'm wondering if there's an customary way.
There are several data access patterns that could apply, in theory. You'd need to provide more detail though if you want us to suggest a specific pattern.
Without more detail, all I can suggest is to consider looking into Martin Fowler's Patterns of Enterprise Application Architecture book.
Edit: Customary way? No, not that I can think of - it really depends on where and how you're using this unique code in your domain. If I were doing this, I'd probably create a small service that speaks directly to the database to perform this function - not as heavy-weight as a repository, and very focused on the problem at hand.
Based on the edit: I would look first at the context in which you need to create that code. Perhaps there are some related entities or something that you are missing.
btw, I find the question really interesting as it comes up from time to time while coding specific features. I usually end up finding I was missing something on the scenario and it ends up fitting well with the normal repository pattern.
After surveying the options I'm going with the Table Gateway pattern.

Resources