[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.gmt.modisco] Re: RelationalWare 2 ModelWare

Hi Jean-Marie,

Thank you for your very interesting post. The problem you are presenting is quite difficult. I will try to answer in two parts.

-- A --

As far as I see, there are three possible solutions for dealing with data from databases as models:

1) You can develop a model handler for ATL giving a metamodel view of your database schemas and model view of your data. This should be quite simple but you need to develop an ad-hoc model handler for each RDBMS system (or at least for JDBC interface). This solution means you are mapping the Relational model as a metametamodel. Here is a sample of a relation (I hope it is self-explanatory):

User(id, name, birthdate, email)
Group(id, name)
UserGroup(id_user,id_group)

With a JDBC model handler, you should be able to query it like this:
helper context MM!User def: GroupName : String =
	self.UserGroup.name;

or

helper def: EclipseMember() : Sequence(MM!User) =
	MM!User.allInstances()->select(e | e.UserGroup.name = 'Eclipse');

It may be a bit though because you have to analyze the DB schema to understand that UserGroup applied to a User is a reference between User and Group because of the primary and foreign keys...

2) You can develop a discoverer like the one available in the MoDisco tool box (http://www.eclipse.org/gmt/modisco/toolBox/RelationalDBInformation/). The main drawback of this method is that target metamodels are fixed. You have then to develop some model transformations to get schema model as a metamodel and your database content model (set of tuples) conforms to this metamodel. It can be tough too.

3) Using some RDBMS-specific tools to extract data and schema from the database in a concrete representation (XML, textual...). It is not a very generic and not very smart, I agree with you. Then, you can develop injectors for these concrete representations and finally define model transformations like in the last step of (2).

Actually, I reckon that the second solution is the most "beautiful" and smart (because it is the most model-driven one). The main drawback is not about the schema but data. It can be very difficult to transform the database content model in another model because of the big semantic gap. It can be solved by keeping a record of the links between this model and the schema model (those links could be kept in a Weaving model for instance :)). Those links would represent the "type" of tuples and tuples' elements. It really is the mu relationship of the RDBM Technical Space that is injected into the modeling world !! A little example:

Let's take the User relation as seen before:
User(id, name, birthdate, email)

and few tuples:
(1;Edsger Dijkstra;19300511;null)
(2;Donald Knuth;19380110;null)

We have to kept in a weaving model, that the first element of the DB content model is linked by mu to the element (probably a Table element) User from the schema model. The first element in the first tuple is linked by mu to the attribute "id" in the relation "User". Etc.

With these information, we would be able to transform everything like described in (2). The issue is the sizes of the models and the execution time of the transformations :)

That's why I think that the solution proposed in (1) may be a good trade off and a very interesting one.

-- B --

Now, the second problem you are leveraging: storing a model in a relational database. Here I see one solution that perfectly fit your needs and another one digressing a bit from it.

1) You can use Teneo (http://www.eclipse.org/modeling/emft/?project=teneo) or something similar that create automatically a mapping between your models and a relational database. It is a technical solution to your question, but it works :) It may have some drawbacks, but more investigation are needed.

2) You can store your models in a Object Database (like DB4O http://db4o.com/). As almost every metametamodel implementation use object oriented paradigm, it should be very easy to make it work. Same as before, more investigation are needed.

I hope it will be helpful.

May the fun be with you too ;)
Mikael


Jean-Marie Favre wrote:
Hi there,
what is currently the best option available (or the various
options) to build injectors or bridges between relational
database to EMF models? They are plenty of things out there
in eclipse, and things are evolving so fast...
Some help appreciated ;-)

In practice we have various database schema and database
(e.g. MySQL) that corresponds to CMS such as joomla, forums,
etc, and we would like to have this data in the form
of a model. We can obviously build ad-hoc tool for each case,
but this is not really smart...

The other way around, is there on the shelve a projector
that take a model and store it to a relational database
given the identification/login/location of the database?

Just let's me know if these are silly questions, or if I should
post them somewhere else, in particular /dev/null ?  or @newbies

May the fun be with you
   Jean-marie



-- Mikaël Barbero - PhD Candidate ATLAS Group (INRIA & LINA) - University of Nantes 2, rue de la Houssinière 44322 Nantes Cedex 3 - France tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00 email: Mikael.Barbero@{gmail.com, univ-nantes.fr} http://www.sciences.univ-nantes.fr/lina/atl/