Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB schema from src

 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Partners!
I have and application which uses database internally without any ORM (plain old sql-scripts against JDBC).
But the problem is I don't have actual database.
Is it possible to reconstruct database schema based on this SQL-scripts? The tool that will parse the source code, find SQL-scripts, determine which table contains which datatype and output a script to create database.
I know that it looks not real, but maybe someone stumbled upon the tool like this. Thanks!
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if a tool exists for this kind of task. I guest you have to do it manually. How many tables you have to create for this program?
 
Tony Docherty
Bartender
Posts: 2989
59
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the sql scripts are all selects, inserts, updates etc rather than creates etc then no you almost certainly won't be able to create an exact schema.
For a start how do you know if the sql scripts you have cover every field and every table in the schema. And even if they do, you may be able to get some of the information required to construct some of the tables but you will be hard pressed to get the exact data type/field widths etc for every field in every table.
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wayan Saryada wrote:How many tables you have to create for this program?

~15 tables with ~10 fields each. It's not precise values because as Tony mentioned, the scripts may not cover all the fields.

Tony Docherty wrote:you may be able to get some of the information required to construct some of the tables but you will be hard pressed to get the exact data type/field widths etc for every field in every table.

So the best solution would be to run the app, see what fields are required, modify schema, drop-create table, run again to see if the script run successfully? That's crazy, but the only way I see to solve this problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic