Skip to content

Commit 1f6bc10

Browse files
committed
add doc for cost model migrators
1 parent cfb1d58 commit 1f6bc10

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

optd-persistent/src/migrator/catalog/m20241029_000001_attribute_constraint_junction.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/*
2-
// The constrained attributes (columns) if a constraint is a table constraint (including foreign keys, but not constraint triggers)
3-
Table attribute_constraint_junction {
4-
attribute_id integer [ref: > attribute.id]
5-
constraint_id integer [ref: > constraint.id]
6-
}
7-
*/
1+
//! An entity representing the relationship between [`attribute`] and [`constraint`].
2+
//!
3+
//! If a constraint is a table constraint (including foreign keys, but not constraint triggers),
4+
//! the attributes that are constrained on are stored in the [`attribute_constraint_junction`].
5+
//!
6+
//! One constraint might be associated with multiple attributes, for example, a composite primary key.
87
98
use crate::migrator::catalog::{attribute::Attribute, constraint::Constraint};
109
use sea_orm_migration::{prelude::*, schema::*};

optd-persistent/src/migrator/catalog/m20241029_000001_attribute_foreign_constraint_junction.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
//! An entity representing the relationship between [`attribute`] and [`constraint`].
2+
//!
3+
//! If a constraint is a foreign key constraint, the attributes that are referenced by the foreign
4+
//! key are stored in the [`attribute_foreign_constraint_junction`]. Note that this is different from
5+
//! the [`attribute_constraint_junction`] table, which stores the attributes that are constrained on.
6+
//! In the case of a foreign key constraint, this refers to the attributes that are referecing from the
7+
//! foreign key.
8+
//!
9+
//! One foreign key constraint might be associated with multiple attributes, for example, a composite
10+
//! foreign key.
11+
112
use crate::migrator::catalog::{attribute::Attribute, constraint::Constraint};
213
use sea_orm_migration::{prelude::*, schema::*};
314

optd-persistent/src/migrator/catalog/m20241029_000001_index.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
Table index {
3-
id integer PK
4-
name varchar
5-
table_id integer [ref: > table_metadata.id]
6-
number_of_attributes integer
7-
is_unique boolean
8-
nulls_not_distinct boolean // Only valid for unique index, if true, then null value is equal, if false, null value is distinct
9-
is_primary boolean
10-
is_clustered boolean // If true, the table was last clustered on this index
11-
is_exclusion boolean // More fields might be added in the future for expressiveness on exclusion constraint.
12-
data json // Stores the attribute ids. The reason for not creating an additional junction table is the same as with the attribute_stats table.
13-
}
14-
*/
15-
161
use crate::migrator::catalog::table_metadata::TableMetadata;
172
use sea_orm_migration::{prelude::*, schema::*};
183

optd-persistent/src/migrator/cost_model/m20241029_000001_statistic_to_attribute_junction.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/*
2-
Table statistic_attribute_junction {
3-
statistic_id integer [ref: > statistic.id]
4-
attribute_id integer [ref: > attribute.id]
5-
}
6-
*/
1+
//! An entity representing the relationship between [`statistic`] and [`attribute`].
2+
//!
3+
//! One [`statistic`] can be associated with multiple [`attribute`]s, which denotes a joint
4+
//! statistic for the attributes. On the other hand, one [`attribute`] can be associated with
5+
//! multiple [`statistic`]s, since the attribute can be used in multiple statistics.
76
87
use crate::migrator::catalog::attribute::Attribute;
98
use crate::migrator::cost_model::statistic::Statistic;

0 commit comments

Comments
 (0)