remodel_core/transform/mod.rs
1//! Transformations between modeling levels.
2//!
3//! The flagship operation is [`conceptual_to_logical`], which mirrors the
4//! `conversorConceitualParaLogico` algorithm from brModelo:
5//!
6//! 1. Each entity becomes a table.
7//! 2. Attributes become columns; complex attributes (composite, multivalued)
8//! are expanded according to [`ConvertOptions`].
9//! 3. Specializations are folded according to a [`SpecializationStrategy`].
10//! 4. Each binary relationship is resolved into either an FK on one side, an
11//! associative table, or a table merge based on its cardinalities.
12//! 5. Ternary and higher-arity relationships always become associative
13//! tables.
14//! 6. Self-relationships are resolved into either a self-referencing FK or an
15//! associative table.
16
17mod conceptual_to_logical;
18mod options;
19
20pub use conceptual_to_logical::conceptual_to_logical;
21pub use options::{ComplexAttributeStrategy, ConvertOptions, RelationshipResolution, SpecializationStrategy};
22
23use crate::error::Result;
24use crate::models::conceptual::ConceptualModel;
25use crate::models::logical::LogicalModel;
26
27impl ConceptualModel {
28 /// Convert this conceptual model into a logical model using the default
29 /// options. See [`conceptual_to_logical`] for the underlying algorithm
30 /// and [`ConvertOptions`] for how to tune it.
31 pub fn to_logical(&self) -> Result<LogicalModel> {
32 conceptual_to_logical(self, &ConvertOptions::default())
33 }
34}