remodel-core is a Rust library for database modeling. It lets you build
conceptual ER models, convert them into logical relational schemas, and render
SQL DDL for supported dialects.
This crate is a Rust reimplementation of the core modeling engine from brModelo by Carlos Henrique Candido and contributors. The port keeps the same GPL-3.0-or-later licensing model.
- Conceptual modeling primitives: entities, attributes, relationships, cardinalities, specializations, unions, and associative entities.
- Logical modeling primitives: tables, columns, primary keys, unique constraints, and foreign keys.
- Conceptual-to-logical transformation with configurable strategies for relationships, specializations, and complex attributes.
- SQL DDL rendering for PostgreSQL, MySQL, and SQLite.
- Validation diagnostics for structurally invalid diagrams.
serdesupport for persistence and interchange formats.
cargo add remodel-coreuse remodel_core::models::conceptual::AttributeOwner;
use remodel_core::prelude::*;
fn main() -> Result<()> {
let mut model = ConceptualModel::new("library");
let book = model.add_entity("Book");
model.add_primary_attribute(book, "id", DataType::Integer)?;
model.add_attribute(
AttributeOwner::Entity(book),
"title",
DataType::Varchar(255),
)?;
let author = model.add_entity("Author");
model.add_primary_attribute(author, "id", DataType::Integer)?;
model.add_attribute(
AttributeOwner::Entity(author),
"name",
DataType::Varchar(120),
)?;
model
.relate("wrote", book, Cardinality::ZeroToMany)
.with(author, Cardinality::OneToMany)
.id();
let logical = model.to_logical()?;
let sql = logical.to_sql(SqlDialect::Postgres);
println!("{sql}");
Ok(())
}This produces a relational model with Book, Author, and a junction table
for wrote.
remodel-core follows the usual database-design flow:
- Build a conceptual model.
- Validate and convert it into a logical model.
- Render SQL DDL for the target database dialect.
The main APIs are:
ConceptualModelfor ER authoringConceptualModel::to_logical()for default conversiontransform::conceptual_to_logical()when you need customConvertOptionsLogicalModel::to_sql()for final DDL generation
- PostgreSQL
- MySQL / MariaDB
- SQLite
The library validates conceptual models before conversion. Structural problems
such as missing references or invalid identifiers are reported through
diagnostics, and conversion returns Error::Validation when errors are present.
Publishing to crates.io is automated through GitHub Actions:
- Push a tag named
remodel-core-vX.Y.Z, or - Run the
Publish remodel-coreworkflow manually.
The workflow runs the crate tests and then publishes RemodelCore/ using the
repository secret CARGO_REGISTRY_TOKEN.
GPL-3.0-or-later.