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:

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

6 Years
Discussion Span
Last Post by smantscheff

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.

Edited by BitBlt: n/a


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?

Edited by capiuy: formatting


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.

Edited by smantscheff: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.