6

I have a database with 193 tables and I need to create an entity-relationship diagram from them. There are no formal relationships between the tables with respect to FKs. The relationships are mapped with 1-* tables.

The database in question is the MusicBrainz database found here.

SchemaSpy doesn't detect the relationships.

Other than myself creating it manually does anyone have any suggestions. Or is anyone familiar with this database that could offer some assistance?

MDCCL
8,5303 gold badges32 silver badges63 bronze badges
asked Nov 20, 2013 at 11:31

5 Answers 5

6

The relationship between tables in any relational database is done using Foreign Keys.

From the Wikipedia definition:

Foreign keys play an essential role in database design. One important part of database design is making sure that relationships between real-world entities are reflected in the database by references, using foreign keys to refer from one table to another.

Without FKs there will be no way for any schema modelling tool of knowing that two tables are related.

A solution might be for you to script out FKs by parsing the names of the tables (if the related tables have similar names), then names and data types of columns that define the relationship. But that's no trivial task.

answered Nov 20, 2013 at 12:19
3
  • the mapping tables take the form l_artist_record joining the tables artist and record through entity0 and entity1. I was hoping there would be an easy way. Commented Nov 20, 2013 at 13:30
  • Wow, not even the naming convention can help. Sorry, except for manual scripting and matching of the needed columns, I don't think any ER tool can scan and display properly that database. Commented Nov 20, 2013 at 14:10
  • 1
    I think I will have to do it manually. Thank you for your help though. Commented Nov 20, 2013 at 15:15
3

There is a package in Debian / Ubuntu family named postgresql-autodoc. Easy to use and generate diagrams in a plethora of formats (.dia, .html, .neato, .dot, .xml)

Hannah Vernon
71.1k22 gold badges178 silver badges324 bronze badges
answered Nov 19, 2015 at 1:02
3

It may be more trouble than its worth but there is a paper on reverse engineering relational database schemas: Clustering relations into abstract ER schemas for database reverse engineering

This paper describes algorithms for inferring relations in the absence of foreign keys. I have implemented parts of this as part of a school assignment with some degree of success.

answered Apr 2, 2019 at 19:54
1

I have a solution for you - Dataedo tool. It reads database schema like other tools, but it's power is you can define missing FKs in the documentation itself (without interfering with database). Then you can create ER diagram from that model. It lets you describe tables and columns (create Data Dictionary) and export it as a complete documentation to PDF and HTML.

I'm the product manager of Dataedo.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
answered Sep 20, 2016 at 22:55
0
0

If you have a bunch of .sql files, you can piece some open source tooling together to achieve what you want.

Look into DBML - "Database Markup Language". It is a platform-agnostic markup language for describing data models.

The first step is to transform your .sql file(s) to dbml.

The next step is to take your .dbml file(s) and generate svg for viewing.

https://github.com/holistics/dbml

https://github.com/softwaretechnik-berlin/dbml-renderer

answered Sep 19, 2021 at 21:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.