Coder Social home page Coder Social logo

cavalcanteleo / dbdia Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edrdo/dbdia

0.0 1.0 0.0 153 KB

Diagram generator for Entity-Relationship models and relational schemas.

License: Apache License 2.0

Shell 0.04% Batchfile 0.03% ANTLR 2.00% Jupyter Notebook 7.88% Java 90.06%

dbdia's Introduction

License: Apache 2.0 GitHub release Travis build Status

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 it 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

Watchers

 avatar

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.