Coder Social home page Coder Social logo

edrdo / dbdia Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 5.0 186 KB

Diagram generator for Entity-Relationship models and relational schemas.

License: Apache License 2.0

Shell 0.04% Batchfile 0.03% ANTLR 1.92% Jupyter Notebook 7.77% Java 90.24%
database diagram graphviz colab er schema antlr java python

dbdia's Introduction

License: Apache 2.0 GitHub release CI

dbdia

Author: Eduardo R. B. Marques

dbdia is open-source software under the terms of the Apache License 2.0.

Summary

dbdia is a diagram generator for database Entity-Relationship (ER) models and relational schemas.

Diagrams are expressed using a domain-specific language that is translated to image format (PNG, PDF, SVG, ...) using the dot tool from Graphviz .

The visual syntax employed by dbdia in ER and relational diagrams mostly follows the conventions of the Fundamentals of Database Systems, 7th edition textbook by Ramez Elmasri and Shamkant B. Navathe.

Run dbdia online using a Colab notebook

Open In Colab

DSL used for ER models and relational schemas

Check here for a description of the DSL used by dbdia.

Examples

Check the examples directory in this repository or in the dbdia release archive. The examples can be also be tested directly in the Colab notebook.

Example ER model Example Schema

Entity definitions

EntityName 
(
  _ KeyField _,
  OptionalField ?,
  . DerivedField ., 
  { MultiValueField },
  CompositeField ( SubField1, { SubField2 }, SubField3 ?, . SubField4 .),
  { ComplexField(SubField1, SubField2(SubField21, SubField22)) } 
)

Entity example

Relationship definitions

EntityA ( ) // with no attributes (just for convenience)
EntityB ( ) // you can in any case ommit attributes in diagrams
EntityC ( ) // using the 'rel' diagram type generation

// Relationship: Rel1 
// Entities involved: EntityA and EntityB
// Cardinality: 1 to N
// Participation: partial for EntityA, total for EntityB
// Relationship attributes: none

EntityA --- 1 --- < Rel1 > === N === EntityB

// Relationship: Rel2
// Entities involved: EntityA and EntityB
// Cardinality: M to N
// Participation: partial for both entities
// Relationship attributes: none

EntityA --- M --- < Rel2 > --- N --- EntityB

// Relationship: Rel3
// Entities involved: EntityA and EntityC
// Cardinality: 1 to 1
// Participation: total for EntityA, partial for EntityC
// Relationship attributes: Rattr1, { RAttr2 } as shown.

EntityA === 1 === < Rel3( RAttr1, { RAttr2 } )> --- 1 --- EntityC

Relationship example

Relational schema definitions

table A
(
  _ PrimaryKey _,
  PlainField, 
  OptionalField ?, 
  ForeignKey1 --> A.PrimaryKey,
  ForeignKey2 --> B.PrimaryKey
)

// Type info is optional - this table has type annotations per each field
// Any identifier is accepted for the type designation.
table B
(
  _ PrimaryKey _ int, 
  PlainField varchar
) 

Schema example

Download, install, and use

Dependencies

  • A Java runtime environment, version 8 or higher.
  • Graphviz

The following should work with recent versions of Ubuntu:

sudo apt install default-jre
sudo apt intall graphviz

Install

  • Download the ZIP of the latest release here.
  • Unzip the release archive to some folder <DBDIA_PATH>
  • The dbdia script (for Linux/MacOS/POSIX) and the dbdia.bat variant for Windows can be found in <DBDIA_PATH>/bin. It may be convenient to add <DBDIA_PATH>/bin to your PATH environment.

Usage

dbdia [-option1=value1 ... -optionk=valuek] <typeOfDiagram> inputFile outputFile

Diagram types

  • er: full ER diagram including entities, entity attributes, and relationships;
  • ent: ER diagram including entities and their attributes only;
  • rel: ER diagram excluding entity attributes;
  • sch: relational schema diagram.

Options

  • Type dbdia help for a list of options.

Compiling from scratch

Requirements:

  • Java JDK (OracleJDK or OpenJDK) for Java 8 or higher
  • Maven 3.x

Commands:

git clone [email protected]:edrdo/dbdia.git
cd dbdia
mvn package 

dbdia's People

Contributors

edrdo avatar w3slley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dbdia's Issues

Bug - parsing stops before EOF

Parser is failing for sequences such as:

a())
b()

(in this case no error is indicated after a() due to the incorrect parenthesis)

Hexadecimal being displayed in .svg file instead of UTF-8 (dbdia 0.3)

When saving the database schema/ER model into a .svg file, this is what I get:
image
It looks like instead of displaying the UTF-8 characters, dbdia is displaying the hexadecimal representation of them. I don't know whether this is an error with my setup or with the tool itself though. I tried saving with other formats (png and jpg) and they are working fine. Have you encounter something like this before?

Thanks in advance.

Web app for project

Hey! Wouldn't it be a good extension to the project to create a basic web application that based on the user input in the front end generates the ER model images in the back end and then displays it to the user? Maybe something similar to what already exists for markdown processing (https://dillinger.io/ for example), but using the dbdia syntax to create them.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.