Documentation
Syntax
Subclass

Subclass/Superclass expression

It is possible to associate different entity types by declaring a subclass/superclass relationship. This is done using the extends keyword when declaring an entity. The following example shows the subclass "Dog" and the superclass "Animal".

entity Animal {
  id key
  age
  location: [latitude, longitude]
}
 
entity Dog extends Animal {
  name
  breed
} 
💡

Subclass entities can't have a key attribute! This is a semantic restriction of the ER model.

The generated ER diagram will contain the special IsA relationship between the superclass and the subclass.

subclass/superclass ER Diagram

You can nest subclasses as deep as you want. The generated ER diagrams will follow a tree-like layout.

💡

If an entity extends one of its subclasses, an error will be shown in the Playground.

entity Employee {
  name
  id key
  bday
}
 
entity Management_Employee extends Employee {}
entity Manager extends Management_Employee {}
entity CEO extends Management_Employee {}
entity Engineer extends Employee {}
entity Senior_Engineer extends Engineer {}
entity Team_Leader extends Senior_Engineer {}
entity Intern extends Engineer {}
entity Secretary extends Employee {
  typing_speed
}
nested subclasses ER Diagram