Learn R Programming

autodb (version 3.2.4)

d2.database: Generate D2 input text to plot databases

Description

Produces text input for D2 to make a diagram of a given database, usually rendered with SVG.

Usage

# S3 method for database
d2(x, name = NA_character_, reference_level = c("attr", "relation"), ...)

Value

A scalar character, containing text input for D2.

Arguments

x

a database.

name

a character scalar, giving the name of the schema, if any.

reference_level

a character scalar, indicating the format to use for foreign key references. "relation" only specifies the relations involved; "attr" also specifies the attributes involved, one pair at a time.

...

further arguments passed to or from other methods.

Details

Each relation in the database is presented as a set of rows, one for each attribute in the relation. These rows include information about the attribute classes.

Any foreign key references are represented by arrows between either the attribute pairs or the relation pairs, depending on the value of reference_level. This allows the output to be geared towards a specific layout engine. Of the engines currently available for D2, Dagre can not plot references between relation attributes, just the attributes themselves, so using reference_level = "relation" prevents compound foreign keys resulting in duplicate reference arrows. ELK and Tala can plot between relation attributes, so the default reference_level = "attr" works as intended.

See Also

The generic d2.