Skip to main content

ErDiagram

The following classes can be useful when creating entity relationship diagrams:

  • siren
  • erDiagram
  • erCardinality
  • erKey

Manufacturer

let CAR, NAMED_DRIVER, PERSON, MANUFACTURER = "CAR", "NAMED-DRIVER", "PERSON", "MANUFACTURER"
siren.erDiagram [
erDiagram.relationship (CAR, erCardinality.onlyOne, NAMED_DRIVER, erCardinality.zeroOrMany, "allows")
erDiagram.entity (CAR, [
erDiagram.attribute("string", "registrationNumber", [erKey.pk])
erDiagram.attribute("string", "make")
erDiagram.attribute("string", "model")
erDiagram.attribute("string[]", "parts")
])
erDiagram.relationship (PERSON, erCardinality.onlyOne, NAMED_DRIVER, erCardinality.zeroOrMany, "is")
erDiagram.entity (PERSON, [
erDiagram.attribute("string", "driversLicense", [erKey.pk], "The license is #")
erDiagram.attribute("string(99)", "firstName", comment="Only 99 characters are allowed")
erDiagram.attribute("string", "lastName")
erDiagram.attribute("string", "phone", [erKey.uk])
erDiagram.attribute("int", "age")
])
erDiagram.entity(NAMED_DRIVER, [
erDiagram.attribute("string", "carRegistrationNumber", [erKey.pk; erKey.fk])
erDiagram.attribute("string", "driverLicence", [erKey.pk; erKey.fk])
])
erDiagram.relationship(MANUFACTURER,erCardinality.onlyOne,CAR,erCardinality.zeroOrMany,"makes")
]
|> siren.write