Jammy
Jammy

Reputation: 87

How to store the relationship into table (ER diagram)

I have a 3x3 data format, and trying to store the relationship into table. Here's how the matrix looks like.

enter image description here

There are several relationships in the matrix that the dots in the corner must be smaller than the neighbor dots.

e.g.

1<2 & 1<4 & 1<5
3<2 & 3<6 & 3<5
7<8 & 7<4 & 7<5
9<8 & 9<6 & 9<5

I tried to create two columns to explain the relationship, but it's hard to avoid the duplicate records in this table. Much appreciated.

Upvotes: 0

Views: 142

Answers (1)

Nic3500
Nic3500

Reputation: 8621

Lets say you have 9 data items, store them in a data table.

Table data
    Index   Value
    1       val1
    2       val2
    3       val3
    4       val4
    5       val5
    6       val6
    7       val7
    8       val8
    9       val9

The relations are based on the values. So you need another table for these relationships.

Table SmallerThan
    Index   Smaller     Bigger
            table.Index table.Index
    1       1           2
    2       1           4
    3       1           5
    4       3           2  
    5       3           6
    6       3           5
    7       7           8
    8       7           4
    9       7           5
    10      9           8
    11      9           6
    12      9           5

Upvotes: 1

Related Questions