I'm having troubles designing the following ERD, I find it extremely hard, so I would appreciate any suggestions on how to resolve it. I need to store sentences in PHP and another ones in JAVA, always mapping them between languages and map their equivalent position between them too, so every position of each sentence should be mapped to the other one.
For example, with this two sentences:
PHP sentence: for ( TRUE )
JAVA sentence: if (VAR++)

I've made an image to show it clearer:
[IMG]http://i51.tinypic.com/2eupdi1.png[/IMG]

I've tried with several designs, with entities for classes, sentence words, and positions but all of them ended up in too many aggregations without doing the right mappings :(
So any help would be most welcome
Regards

Recommended Answers

All 4 Replies

i really do not understand, based on what you want to establish the relationships between the objects.

Part of the problem I see is that you are trying to force semantic equivalence on non-mappable syntax. Ever heard of a book called "Godel, Escher, Bach: An Eternal Golden Braid" by Douglas Hofstadter? He has some interesting chapters on reductionism vs. holism. Your design attempt sits squarely on that boundary.

Without going too deeply into it, he points out that at a certain hard-to-define level, as you break down an item into its constituent parts it loses its semantic meaning and just becomes a jumble of bits and pieces. Your attempt to map between the two languages here is like that...there's no clean mapping. You lose semantic equivalence somewhere, and so the mapping becomes meaningless.

You may want to do a little more thinking about what you're trying to accomplish and try to get your head around what you're actually trying to map. Is it some sort of functionality unit (such as a loop, a conditional, an assignment, etc.)? Or is it a syntactical equivalence (such as "case..." vs. "switch..."). Until you get that worked out, it will be impossible to create a relational design to capture it.

I don't mean to discourage you...keep going. Just make sure you understand what you're attempting, otherwise you'll spend a long frustrating time and wind up with nothing.

BitBlt, I appreciate your opinion, I had never heard about that book and while looking for reviews about it, seems to be very interesting, so It has become one of my pending books to read ;)
Besides the semantic involved on those sentences, doing the mapping is a key part of the app that I'm developing. so it has sense in such context, but I understand your point anyway.
Some of my attempts in resolving it are:

_____________________________________
|                  index_position   |
|                   /               |
| ____________     /  ____________  |
| | SENTENCE |___/\___| SENTENCE _| |
| |__________|   \/   |_COMPONENT_| |
|   |  |         |                  |
|  /\__|     ____|_____             |_______/\
|  \/        | CLASS  |             |       \/ column
| sentence   |________|             |________| equivalent
| equivalent                        |
|___________________________________|

another try:
_______________________________________
| __________________________________  |
| | _________        ____________  |  |
| | | CLASS |___/\___| SENTENCE _| |  |
| | |_______|   \/   |_COMPONENT_| |  |
| |________________________________|  |
|                |                    |
|               /\                    |
|               \/                    |
|          ______|______              |
|          | POSITION  |              |
|          |___________|              |______
|_____________________________________|      |
                 |             |             |
                 |             |____________/\ column equivalent
                 |                          \/
                /\                    
                \/                    
           ______|______              
           | SENTENCE  |________              
           |___________|       |       
                 |____________/\ sentence equivalent
                              \/

but I don't see any better solution for it.. any idea?

If you really want to achieve this kind of translation you need a higher level representation of the statements to be translated. On which level does the PHP "for" statement match the JAVA "if" statement and vice versa? If it does, it will be on the level of program flow logic. For that you will have to find an abstraction which matches both languages. There is no guarantee that for each language construct element in one language there will be a matching element in the other one. Consider the empty parameter loop "for (;;)" which is perfectly valid in C but not elsewhere.
If there were an equivalent for each language element in the other language, they would only differ in keywords and their order (and things like statement delimiters and brackets).
Beyond "Gödel, Escher, Bach" I recommend reading about Compiler construction which has to tackle this kind of problems.
I pretty much doubt that a relational database will help you much here. A formal representation in XML/XSLT might be easier.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.