liveBook · Manning

Object-relation diagram notation

As explained in Building User-Friendly DSLs

A graphical notation for representing structured data as objects with properties and relations.

Object-relation diagram (ORD) notation represents one concrete piece of structured data as objects, their simple properties, and relations between them. It makes DSL content’s structure visible before that structure is encoded in code. section 2.0 section 2.1

An object is drawn as a box with a concept label above and zero or more simple settings below. A setting has the form property = value; values may be strings, numbers, Booleans, or enumerated values. A name setting conventionally lets an object be identified by that name. section 2.1

Use ORDs to distinguish the data at hand from a model of permitted data:

  • An ORD shows actual objects, the data they hold, and their relations in a particular diagram. section 2.1
  • An entity-relationship diagram describes possible entities, data, and relations across a context rather than one particular data instance. section 2.1
  • Containment relations organize objects into a tree when reference relations are disregarded; that tree-shaped form is an abstract syntax tree (AST). section 2.3

Extracting a Rental record type

Start with the Rental definition in concrete syntax. Represent the whole definition as a Record Type object, add name = Rental, then create Attribute objects for its four attributes. Connect those attributes through containment relations, add their name and type settings, and represent initial values either as simple values or references. The completed ORD is the definition’s abstract syntax. section 2.2

Extraction reduces concrete syntax to essential information while ignoring notational detail. Visual cues such as keywords, symbols, boxes, arrows, and layout guide the extraction. The reverse direction reconstructs concrete syntax from an AST and underpins a DSL editor visualization. section 2.0 section 2.2

Figure 2.17 The end result of the extraction process
figure

Inspect the completed Rental extraction to see objects, simple settings, containment, and a reference relation together. section 2.2

ORDs remain useful after extraction because they visualize ASTs and algorithms without tying the explanation to a chosen programming language. The notation itself can be viewed as a small DSL for representing structured data. section 3.3.3

How Building User-Friendly DSLs covers it

How deep it goes
Defines object boxes, labels, simple settings, relations, extraction, and AST layout; defers code encoding and later transformations.
Examples
Walks through extracting a Rental record type and its four attributes into objects, settings, containment relations, and a reference.
What it assumes
Teaches the notation from zero while assuming familiarity with DSL content and its underlying structure.
What you can do after
Evaluate/understand structured DSL data by drawing ORDs and reducing concrete syntax to an abstract syntax tree.
How it connects
Connects concrete syntax, abstract syntax, abstract syntax trees, containment relations, reference relations, projections, and DSL editors.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.