Skip to content

7.1. Database Schema

Kirill Kovtun edited this page Jun 11, 2026 · 1 revision

English | Русский

English

7.1 Database Schema Specification

7.1.1 Purpose

The Database Schema diagram type is used to describe the physical structure of a database.

Its primary purpose is to model tables, columns, relationships, and other database objects in a structured and implementation-oriented form.

The Database Schema diagram type focuses on how data is stored and connected within a database system.


7.1.2 Scope

Database Schema models may be used to describe:

  • Relational database structures
  • Tables and columns
  • Primary keys
  • Primary-key, uniqueness, nullability, and auto-increment column properties
  • Foreign-key roles derived from relationship source columns
  • Enumerations
  • Seed or example data
  • Relationships between tables

Database Schema models are not intended to replace conceptual domain modeling, business modeling, or software architecture diagrams.


7.1.3 Core Concepts

Database Schema models are built around a small set of core concepts.

Table

A table represents a collection of records stored in a database.

Tables are the primary structural elements of a Database Schema model.

Column

A column represents a single attribute stored within a table.

Each column has a defined data type and may define supported column properties.

Relationship

A relationship represents a connection between tables.

Relationships are directed references between columns in different tables. The source column has the foreign-key role for rendering and validation purposes; there is no standalone foreign-key declaration in the MVP.

Enumeration

An enumeration defines a predefined set of allowed values.

Record

A record represents example, seed, or reference data associated with a table.

7.1.4 Elements

Database Schema models may contain the following element types:

  • table
  • column
  • enum
  • relationship
  • records

Each element type represents a different part of a physical database structure.


Table

A table represents a database table.

A table contains column declarations.

table users {
    column id int;
    column email string;
};

Column

A column represents a field stored inside a table.

A column must belong to a table and must define a data type.

table users {
    column id int;
    column email string;
};

Columns may also use block syntax when additional properties are required.

table users {
    column id int {
        pk;
        auto_increment;
    };

    column email string {
        unique;
        not_null;
    };
};

Enum

An enum represents a predefined set of allowed values.

Enums may be used as column types.

enum order_status {
    pending;
    paid;
    shipped;
    cancelled;
};

table orders {
    column status order_status;
};

Relationship

A relationship represents a connection between tables.

Relationships are usually based on references between columns.

relationship user_orders {
    orders.user_id -> users.id;
};

Database relationships are directed references. Cardinality is not inferred in the MVP.


Records

A records block represents example, seed, or reference data for a table.

records users {
    { id: 1, email: "alice@example.com" };
    { id: 2, email: "bob@example.com" };
};

Records are optional and should not be required for rendering the database structure.

Русский

7.1 Спецификация Database Schema

7.1.1 Назначение

Тип диаграммы Database Schema предназначен для описания физической структуры базы данных.

Основная задача данного типа диаграмм — моделирование таблиц, колонок, связей и других объектов базы данных в структурированной форме, близкой к реализации.

Database Schema сосредоточен на том, как данные хранятся и связаны между собой внутри системы хранения данных.


7.1.2 Область применения

Модели Database Schema могут использоваться для описания:

  • Структур реляционных баз данных
  • Таблиц и колонок
  • Первичных ключей
  • Свойств колонок для первичного ключа, уникальности, обязательности и автоинкремента
  • Роли внешнего ключа, выводимой для исходной колонки связи
  • Перечислений
  • Тестовых, справочных и начальных данных
  • Связей между таблицами

Модели Database Schema не предназначены для замены концептуального моделирования предметной области, бизнес-моделирования или архитектурных диаграмм.


7.1.3 Основные концепции

Модели Database Schema строятся вокруг небольшого набора базовых концепций.

Table

Таблица представляет собой набор записей, хранящихся в базе данных.

Таблицы являются основными структурными элементами модели Database Schema.

Column

Колонка представляет отдельный атрибут, хранящийся в таблице.

Каждая колонка имеет определённый тип данных и может содержать поддерживаемые свойства колонки.

Relationship

Связь представляет отношение между таблицами.

Связи являются направленными ссылками между колонками разных таблиц. Исходная колонка получает роль внешнего ключа для целей валидации и визуализации; отдельного объявления внешнего ключа в MVP нет.

Enumeration

Перечисление определяет заранее заданный набор допустимых значений.

Record

Запись представляет тестовые, справочные или начальные данные, связанные с таблицей.

7.1.4 Элементы

Модели Database Schema могут содержать следующие типы элементов:

  • table
  • column
  • enum
  • relationship
  • records

Каждый тип элемента описывает отдельную часть физической структуры базы данных.


Table

table представляет таблицу базы данных.

Таблица содержит объявления колонок.

table users {
    column id int;
    column email string;
};

Column

column представляет поле, хранящееся внутри таблицы.

Колонка должна принадлежать таблице и должна иметь тип данных.

table users {
    column id int;
    column email string;
};

Колонки могут использовать блочный синтаксис, если им нужно задать дополнительные свойства.

table users {
    column id int {
        pk;
        auto_increment;
    };

    column email string {
        unique;
        not_null;
    };
};

Enum

enum представляет заранее заданный набор допустимых значений.

Перечисления могут использоваться как типы колонок.

enum order_status {
    pending;
    paid;
    shipped;
    cancelled;
};

table orders {
    column status order_status;
};

Relationship

relationship представляет связь между таблицами.

Обычно связи основаны на ссылках между колонками.

relationship user_orders {
    orders.user_id -> users.id;
};

Связи баз данных являются направленными ссылками. В MVP кардинальность не выводится.


Records

Блок records представляет тестовые, начальные или справочные данные для таблицы.

records users {
    { id: 1, email: "alice@example.com" };
    { id: 2, email: "bob@example.com" };
};

Записи являются необязательными и не должны требоваться для визуализации структуры базы данных.