Most relational databases are fundamentally imperative: your schema exists as a running sequence of modification commands, usually scattered across a heap of migration scripts. Suffice it to say, that is far from a human-friendly way to describe a schema.
Hunting for friendlier modeling tools, developers often reach for ORM libraries or NoSQL stores, each of which arrives with its own set of tradeoffs.
Relvyn resolves this by shipping a first-party declarative schema modeling language that is woven deeply into Relvyn's query language, type system, and migration tools.
Schemas are built from object types—the counterpart to tables in SQL—that carry properties and links to other objects. Those "link" fields make foreign key constraints unnecessary.
type User {
required first_name: str;
middle_name: str;
}
No "id" property is required, as Relvyn automatically generates a unique ID for every object in the database.
Relvyn's type system was engineered from the ground up for consistency and safety. Every value that Relvyn stores is strongly typed, no exceptions.
str
bool
int{16|32|64}
float{32|64}
bigint
decimal
sequence
datetime
duration
cal::local_datetime
cal::local_date
cal::local_time
uuid
json
enum<X,Y,[...]>
These scalar types underpin Relvyn's type system, can be used as properties or composed into arrays and tuples. Read the Scalar docs for details, methods, and operators for each type.
Relvyn brings in the idea of "links" for connecting objects to one another directly, which removes any need for foreign key constraints.
type User {
required email: str;
}
type BlogPost {
required content: str;
required author: User;
}Modeling a one-to-many relation is simple and intuitive. Under the hood, a foreign key column referencing User will be added to the BlogPost table.
Relvyn is no toy database. It sets out to match or exceed SQL in capability, expressiveness, consistency, and elegance.
module auth {
type User {
# properties...
};
}
module models {
type BlogPost {
author: auth::User;
};
}Schemas can be split up into logical units called modules.
You can choose whether to define your whole schema inside the "default" module or split it into several. If you split it up, use the "{module}::" namespace prefix when referencing the type in other modules.