Author: Eduardo R. B. Marques
dbdia is open-source software under the terms of the Apache License 2.0.
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.
Check here for a description of the DSL used by dbdia.
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.
EntityName
(
_ KeyField _,
OptionalField ?,
. DerivedField .,
{ MultiValueField },
CompositeField ( SubField1, { SubField2 }, SubField3 ?, . SubField4 .),
{ ComplexField(SubField1, SubField2(SubField21, SubField22)) }
)
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
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
)
- 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
- 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.
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.
Requirements:
- Java JDK (OracleJDK or OpenJDK) for Java 8 or higher
- Maven 3.x
Commands:
git clone git@github.com:edrdo/dbdia.git
cd dbdia
mvn package