ERD (Entity-Relationship Diagram) Family
Entity-Relationship Diagrams with entities, attributes, relationships, row-level connection points, multiplicity markers (1:1, 1:N, M:N), and DDL export.

Overview
Base Control: ERDControl : MaterialControl
Namespace: Beep.Skia.ERD
The ERDControl is the root control for this diagram family. It inherits MaterialControl and provides shared port management, styling, and template methods for all nodes in the family.
This family contains 4 node types.
Node Types
| Node Class | Shape | Description |
|---|---|---|
ERDEntity | Table rectangle | Database table with columns, primary keys, foreign keys, and row-level connection points for per-column relationships. |
ERDAttribute | Oval | Entity attribute with name, data type, and nullable flag. |
ERDRelationship | Diamond | Relationship between entities with cardinality (1:1, 1:N, M:N) and Crow's Foot notation. |
DDLExporter | N/A (utility) | Generates CREATE TABLE SQL from ERDEntity definitions including PKs, FKs, indexes, and constraints. |
ERDEntity
Database table with columns, primary keys, foreign keys, and row-level connection points for per-column relationships.
| Shape | Table rectangle |
|---|---|
| Input Ports | 2+ (left) |
| Output Ports | 2+ (right) |
ERDAttribute
Entity attribute with name, data type, and nullable flag.
| Shape | Oval |
|---|---|
| Input Ports | 1 |
| Output Ports | 1 |
ERDRelationship
Relationship between entities with cardinality (1:1, 1:N, M:N) and Crow's Foot notation.
| Shape | Diamond |
|---|---|
| Input Ports | 2+ (left/top) |
| Output Ports | 2+ (right/bottom) |
DDLExporter
Generates CREATE TABLE SQL from ERDEntity definitions including PKs, FKs, indexes, and constraints.
| Shape | N/A (utility) |
|---|---|
| Input Ports | — |
| Output Ports | — |
Connection Points
Every node in this family exposes connection points (ports) for linking to other nodes. Port positions are computed lazily by LayoutPorts(), which runs when MarkPortsDirty() flags the layout as stale after a move or resize.
| Node Class | Input Ports | Output Ports | Extra |
|---|---|---|---|
ERDEntity | 2+ (left) | 2+ (right) | 1 per field (left/right) |
ERDAttribute | 1 | 1 | — |
ERDRelationship | 2+ (left/top) | 2+ (right/bottom) | — |
DDLExporter | — | — | — |
Connection Conventions
When building diagrams with this family, follow these conventions:
- ERDEntity uses row-level connection points for per-column relationships
- Multiplicity markers displayed on line endpoints (1, N, M)
- DDLExporter generates SQL from entity metadata
- ConnectionPoint.DataType and RowId enable schema validation
Usage Example
Complete example showing creation, node placement, and connection:
C# Example
var erd = new ERDControl
{
X = 100, Y = 50,
Width = 700, Height = 500
};
drawingManager.AddComponent(erd);
var entity = new ERDEntity
{
X = 200, Y = 100,
TableName = "Customers",
Width = 200, Height = 150
};
entity.AddField("Id", "int", isPrimaryKey: true);
entity.AddField("Name", "varchar(100)");
entity.AddField("Email", "varchar(255)");
drawingManager.AddComponent(entity);
var attr = new ERDAttribute
{
X = 450, Y = 100,
AttributeName = "Email",
DataType = "varchar(255)"
};
drawingManager.AddComponent(attr);
var rel = new ERDRelationship
{
X = 200, Y = 300,
RelationshipType = RelationshipType.OneToMany,
Text = "places"
};
drawingManager.AddComponent(rel);
// Row-level connections with multiplicity
drawingManager.ConnectComponents(entity.GetFieldPoint("Id"), rel.InPoints[0]);
drawingManager.ConnectComponents(rel.OutPoints[0], attr.InPoints[0]);
// Export DDL
var exporter = new DDLExporter();
string sql = exporter.Export(entity);