neojjang / wwwsqldesigner

Automatically exported from code.google.com/p/wwwsqldesigner
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Better Positioning Algorithm #74

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load data from a large database

What is the expected output? What do you see instead?
You expect the job to be done, whilst the relations can't be read, because 
they superpose.

What version of the product are you using? On what operating system?
2.4 / Chrome / XP

Please provide any additional information below.

What I did is not perfect, but might give you some ideas :
 1. place the tables with only 1 relation on a large circle (outer circle)
 2. place the tables with at most 1 relation per row on a less large circle 
(inner circle)
 3. place the tables without relation elsewhere (for exemple, from the 
bottom left to the bottom right outside of the circle)
 4. place all other tables in a rotate square so that they do not align 
horizontaly
           x
      x   
           x
      x
 5. reorder the tables from the 1st step so they get closer to their unique 
related table
 6. reorder the tables from the 4th step so theyre relation count is with a 
better repartion
       9 8 7        9 5 8
       6 5 4   =>   2 1 4
       3 2 1        6 3 7

You've already seen the result ;)
 http://maintenance.netsoins.org/dbdesign/

It is not perfect, I think it lack some reordering of the inner circle, and 
no taking count of self-to-self relations :
      +---+
   ---|   |-
      |   | |  this table has two relations but the shall count as one
      |   |-
      +---+

There is a lot of work for this issue, you can read what I uglyly did :
 > SQL.Designer.prototype.alignTables
 http://maintenance.netsoins.org/dbdesign/js/wwwsqldesigner.js

Original issue reported on code.google.com by geompse@gmail.com on 14 Mar 2010 at 12:52

GoogleCodeExporter commented 9 years ago
I am open to a patch here. When you are happy with your algorithm, just send me 
a
diff and I will see if it creates better results :)

Original comment by ondrej.zara on 14 Mar 2010 at 7:41

GoogleCodeExporter commented 9 years ago
Well I needed to show him that what my boss asks is something very difficult... 
since this 
goal is reached, I won't go farther in this process. I'm quite sure that you 
know what at 
pain it is.... :)

I had problems with some configurations.

Like this :

  [table1]---[table2]---[table3]
      > is table1 related with table3
      > is table1 related with table2
      > is table2 related with table3

Solution :

   [table1]--------------[table2]
            \   
             -[table3]

Colors also helps a lot !

Original comment by geompse@gmail.com on 14 Mar 2010 at 9:59