Sort exported SQL data according to dependency order
a
anonymous
started a topic
over 11 years ago
[This topic is migrated from our old forums. The original author name has been removed]
In Export Database, would it be possible to export the SQL data according to dependecy order (parent records first, then child records)? It seems to me the order is alphabetical according to table name.
Output Format: SQL
Object Types: Tables
Generate CREATE Statements: unchecked
Generate DROP Statemetns: unchecked, disabled
Include Table Indexes: Unchecked
Include Table Data: Checked
Re: Sort exported SQL data according to dependency order
Hi Geff,
We have received this request before so I'll add your vote for it. Finding dependencies may not always be possible, so would allowing manual ordering be a workable solution for you?
Best Regards,
Hans
a
anonymous
said
over 11 years ago
[This reply is migrated from our old forums. The original author name has been removed]
Re: Sort exported SQL data according to dependency order
Couldn't the map / chart in the References tab be used to manage / sort the dependencies / FKs (ignoring self-references, since that's another issue), at least for the sequence of tables to be inserted?
You could add a checkbox to enable the sorted option, so that those who are OK with the current export still get it (in a much quicker way).
Your other suggestion to manually order the tables is also OK, although that would be quite tiresome and still error-prone (if you don't know all the dependencies).
Hans Bergsten
said
over 11 years ago
[This reply is migrated from our old forums.]
Re: Sort exported SQL data according to dependency order
Hi Geff,
It may be possible to use the same info as for the References tab, but it could be a slow process. There are also some details to deal with, such as if you mark that you want to export a table that has an FK to another, but you do not mark the referenced table, should it still be exported? Things like this can be worked out with various options, but it may end up being a hard-to-understand feature.
Also, I'm not sure I really understand why this is an issue. The generated CREATE statements do not include any FK constraints; they are added at the end using ALTER statements. This should mean that all tables should be created without errors, regardless of dependencies. What am I missing/
Best Regards,
Hans
a
anonymous
said
over 11 years ago
[This reply is migrated from our old forums. The original author name has been removed]
Re: Sort exported SQL data according to dependency order
I agree with Hans. My first thought when I read this post was "what's the use case?". My second was "Boy! That would be REALLY hard to program". Self-referencing tables would be just one issue. How do you distinguish parent/child relationships from links to lookup tables? What about circular references?
My suggestion would be to name your DB tables to show the parent/child relationship. For example, a healthcare DB might have tables like Patient, Patient_Address, Patient_Insurance, etc. Then they'll sort the way you want, even in the DbVisualizer objects tree. Abbreviations can be used to make the table names shorter, as long as you establish a naming convention and stick to it.
anonymous