Table of Contents

Class Database

Namespace
YndigoBlue.Velocity.Model
Assembly
YndigoBlue.Velocity.dll

Represents a database containing multiple schemas.

public class Database : IEquatable<Database>
Inheritance
Database
Implements

Remarks

Warning

Multi-schema database support is not available in the Community Edition of Velocity. It requires the Full Edition. The Community Edition supports single-schema operations only.

Database provides a higher-level abstraction for managing multiple related schemas as a single unit. This enables multi-schema applications, cross-schema relationships, and unified deployment operations.

Databases can be created programmatically using NewDatabase(string, OriginType), loaded from declarative files, or loaded from existing databases.

Examples

Creating a multi-schema database:

// Create a database with multiple schemas
Database db = Database.NewDatabase("my_application");

// Create schemas for different application domains
Schema usersSchema = db.CreateSchema("users");
Schema ordersSchema = db.CreateSchema("orders");
Schema inventorySchema = db.CreateSchema("inventory");

// Define tables in users schema
Table usersTable = usersSchema.CreateTable("accounts");
usersTable.CreateColumn("user_id", DataType.Long, autoGenerate: true, notNull: true);
usersTable.CreateColumn("username", DataType.VarChar, size: 100, notNull: true);

// Define tables in orders schema
Table ordersTable = ordersSchema.CreateTable("orders");
ordersTable.CreateColumn("order_id", DataType.Long, autoGenerate: true, notNull: true);
ordersTable.CreateColumn("user_id", DataType.Long, notNull: true);

// Create cross-schema foreign key
ordersTable.AddForeignKey(
    "fk_orders_users",
    ordersTable["user_id"],
    usersTable["user_id"]
);

// Deploy all schemas together
using (Manager manager = new Manager(connection))
{
    manager.BuildDatabase(db);
}

Properties

this[string]

Gets the schema with the specified name from this database.

Name

Gets or sets the name of the database.

Origin

Gets the origin type of this database (Memory, File, or Database).

SchemaNames

Gets the ordered list of schema names in this database.

Schemas

Gets the ordered list of schemas in this database.

Methods

AddSchema(Schema)

Adds an existing Schema to this database.

AddSchemaRange(IEnumerable<Schema>)

Adds a collection of schemas to this database. Null collections are silently ignored.

CreateSchema(string)

Creates a new Schema within this database and registers it.

Equals(Database)

Performs a deep structural comparison of two databases, comparing all contained schemas.

GetSchema(string)

Returns the schema with the specified name from this database.

NewDatabase(string)

Creates a new in-memory Database with the specified name.

ToString()

Returns the database name as a string representation.