jvargas
jvargas

Reputation: 843

How to generate SQLite entity relationship diagram from database file

I am trying to reverse engineering to a database file that an android application generates. It gives me a SQLite file in .db extension. I tried pass it through SQLite Browser and it gets me the tables, but no relationships also every table givesme "id" for primary key. Any help or suggestions on how to approach this would be great, thanks!

Upvotes: 26

Views: 56091

Answers (8)

nicholas wolff
nicholas wolff

Reputation: 1

I use https://dbdiagram.io/

  1. Export just the schema from the sqlite database
    sqlite3 c:/sqlite/mydatabase.db
    .output c:/export/mydatabase.sql
    .schema
    .exit
  1. Go to https://dbdiagram.io/ . It's free but you need to login
  2. New diagram
  3. Import -> "From MySQL". It worked for me even though the ddl comes from sqlite
  4. The diagram gets automatically generated but the layout is not great, you can move around your entities and the relationships relayout automatically.

Resulting diagram

Upvotes: 0

bl3ssedc0de
bl3ssedc0de

Reputation: 1015

For me it worked using DBeaver universal database

Convert SQLite file with .db extension to an ER diagram..

ER diagram sqlite3 database

Upvotes: 10

DocZen
DocZen

Reputation: 41

You may use SQLite Schema Diagram Generator

enter image description here

Upvotes: 1

MAljelm
MAljelm

Reputation: 21

using DBVisualizer

  1. click [DOWNLOAD FOR FREE]
  2. install and selecet [free forever] at the end, Note:(could not find a way change to trail after)
  3. run the app and click [+] to add a new data base connection
  4. type [SQLite] in search bar
  5. under [Database file name] click the drop down arrow and load file
  6. follow freshpasta answer: expand the following [created data base>Schema] then click on [Tables] to [Open Object] and select [References] tab. which shows the entity relationship diagram.

Upvotes: 1

SJOE
SJOE

Reputation: 21

A bit late but if you got IntelliJ IDE product you can connect to your "Database" and generate a diagram for it.

https://www.jetbrains.com/help/pycharm/creating-diagrams.html

Note: IntelliJ is paid tool,so you may need a paid version for this trick Or just enable free trial till you do this task.

References https://www.jetbrains.com/products/compare/?product=idea&product=idea-ce https://www.jetbrains.com/datagrip/features/

Upvotes: 2

Sualeh Fatehi
Sualeh Fatehi

Reputation: 39

The quickest way to do this is by using the SchemaCrawler web application. If you need to keep your database private, you can use the approach suggested by @freshpasta

Upvotes: 3

freshpasta
freshpasta

Reputation: 616

After extensive search, I found that you can do it without running a server using DBVisualizer. After you install DBVisualizer, import your database, then expand the database connection which is on the left under Connections, expand schema then double click Tables. Switch to References tab in the pane on the right and you'll have your diagram.

I have also found about SchemaCrawler which is free and open source unlike DBVisualizer and also doesn't require running a server, but have yet to get it to work. You can follow this guide if you wish to use this instead.

Example of ER diagram generated by DBVisualizer

Upvotes: 23

Payal
Payal

Reputation: 44

In the MySQL workbench select Database option from the menus available on the top of the screen,there you will get reverse engineer option. Click on it then select your server and database on which you want to create ER diagram and click next.

Upvotes: 1

Related Questions