Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

Consider the following output of a xml-file:

XML
<PACKET name="abc">
        <VARREF name="X_PACKET"         size="8"/>
        <VARREF name="Y_PACKET"         size="16"/>
        <SPARE                              size="7"/>
        <VARREF name="Z_PACKET"         size="1"/>
        <SPARE                              size="8"/>

        <IF var="Z_PACKET" val="0">
            <VARREF name="PACKET ABC"   size="8"/>
            <VARREF name="PACKET CBA"   size="8"/>
        </IF>
        <IF var="Z_PACKET" val="1">
            <VARREF name="PACKET123"        size="8"/>
            <VARREF name="PACKET321"    size="8"/>
        </IF>
        <SPARE                                  size="7"/>
        <VARREF name="ABCPACKET"    size="1"/>
        <VARREF name="BCDPACKET"            size="16"/>

</PACKET>



Now i want to convert this xml-strucuture into Database-tables (MySQL).

I have the following tables:

Table: Packet (Variables: Packetname)
Table: Signal (Variables: name(Packetname), size, val)
relationship: n:m

That means: one packet could contain n-signals and a signal can belong to more packets.

Now I don´t know how to convert an if-statement into a table, because the content of the table packet depends on the variable "val". That means, depending on the attribute "val" of the Signal table the content of the database-table Packet is different.


Sorry for my bad english

regards
Posted

1 solution

The solution: I have to add an additional m:n-Relationship to the table Signal. In the new created table Signal_has_Signal i´m able to add many SignalID´s to one special SignalID. Through Select-Statements I´m able to view the correct Packet-Structure(Table Packet).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900