pub struct Table {Show 24 fields
pub id: Uuid,
pub name: String,
pub columns: Vec<Column>,
pub database_type: Option<DatabaseType>,
pub catalog_name: Option<String>,
pub schema_name: Option<String>,
pub medallion_layers: Vec<MedallionLayer>,
pub scd_pattern: Option<SCDPattern>,
pub data_vault_classification: Option<DataVaultClassification>,
pub modeling_level: Option<ModelingLevel>,
pub tags: Vec<Tag>,
pub odcl_metadata: HashMap<String, Value>,
pub owner: Option<String>,
pub sla: Option<Vec<SlaProperty>>,
pub contact_details: Option<ContactDetails>,
pub infrastructure_type: Option<InfrastructureType>,
pub notes: Option<String>,
pub position: Option<Position>,
pub yaml_file_path: Option<String>,
pub drawio_cell_id: Option<String>,
pub quality: Vec<HashMap<String, Value>>,
pub errors: Vec<HashMap<String, Value>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Table model representing a database table or data contract
A table represents a structured data entity with columns, metadata, and relationships. Tables can be imported from various formats (SQL, ODCS, JSON Schema, etc.) and exported to multiple formats.
§Example
use data_modelling_core::models::{Table, Column};
let table = Table::new(
"users".to_string(),
vec![
Column::new("id".to_string(), "INT".to_string()),
Column::new("name".to_string(), "VARCHAR(100)".to_string()),
],
);§Example with Metadata (Data Flow Node)
use data_modelling_core::models::{Table, Column, InfrastructureType, ContactDetails, SlaProperty};
use serde_json::json;
let mut table = Table::new(
"user_events".to_string(),
vec![Column::new("id".to_string(), "UUID".to_string())],
);
table.owner = Some("Data Engineering Team".to_string());
table.infrastructure_type = Some(InfrastructureType::Kafka);
table.contact_details = Some(ContactDetails {
email: Some("team@example.com".to_string()),
phone: None,
name: Some("Data Team".to_string()),
role: Some("Data Owner".to_string()),
other: None,
});
table.sla = Some(vec![SlaProperty {
property: "latency".to_string(),
value: json!(4),
unit: "hours".to_string(),
description: Some("Data must be available within 4 hours".to_string()),
element: None,
driver: Some("operational".to_string()),
scheduler: None,
schedule: None,
}]);
table.notes = Some("User interaction events from web application".to_string());Fields§
§id: UuidUnique identifier for the table (UUIDv4)
name: StringTable name (must be unique within database_type/catalog/schema scope)
columns: Vec<Column>List of columns in the table
database_type: Option<DatabaseType>Database type (PostgreSQL, MySQL, etc.) if applicable
catalog_name: Option<String>Catalog name (database name in some systems)
schema_name: Option<String>Schema name (namespace within catalog)
medallion_layers: Vec<MedallionLayer>Medallion architecture layers (Bronze, Silver, Gold)
scd_pattern: Option<SCDPattern>Slowly Changing Dimension pattern (Type 1, Type 2, etc.)
data_vault_classification: Option<DataVaultClassification>Data Vault classification (Hub, Link, Satellite)
modeling_level: Option<ModelingLevel>Modeling level (Conceptual, Logical, Physical)
Tags for categorization and filtering (supports Simple, Pair, and List formats)
odcl_metadata: HashMap<String, Value>ODCL/ODCS metadata (legacy format support)
owner: Option<String>Owner information (person, team, or organization name) for Data Flow nodes
sla: Option<Vec<SlaProperty>>SLA (Service Level Agreement) information (ODCS-inspired but lightweight format)
contact_details: Option<ContactDetails>Contact details for responsible parties
infrastructure_type: Option<InfrastructureType>Infrastructure type (hosting platform, service, or tool) for Data Flow nodes
notes: Option<String>Additional notes and context for Data Flow nodes
position: Option<Position>Canvas position for visual representation
yaml_file_path: Option<String>Path to YAML file if loaded from file system
drawio_cell_id: Option<String>Draw.io cell ID for diagram integration
quality: Vec<HashMap<String, Value>>Quality rules and checks
errors: Vec<HashMap<String, Value>>Validation errors and warnings
created_at: DateTime<Utc>Creation timestamp
updated_at: DateTime<Utc>Last update timestamp
Implementations§
Source§impl Table
impl Table
Sourcepub fn new(name: String, columns: Vec<Column>) -> Table
pub fn new(name: String, columns: Vec<Column>) -> Table
Create a new table with the given name and columns
§Arguments
name- The table name (must be valid according to naming conventions)columns- Vector of columns for the table
§Returns
A new Table instance with a generated UUIDv4 ID and current timestamps.
§Example
use data_modelling_core::models::{Table, Column};
let table = Table::new(
"users".to_string(),
vec![Column::new("id".to_string(), "INT".to_string())],
);Sourcepub fn get_unique_key(
&self,
) -> (Option<String>, String, Option<String>, Option<String>)
pub fn get_unique_key( &self, ) -> (Option<String>, String, Option<String>, Option<String>)
Get the unique key tuple for this table
Returns a tuple of (database_type, name, catalog_name, schema_name) that uniquely identifies this table within its scope. Used for detecting naming conflicts.
§Returns
A tuple containing the database type (as string), name, catalog name, and schema name.
Sourcepub fn generate_id(
_name: &str,
_database_type: Option<&DatabaseType>,
_catalog_name: Option<&str>,
_schema_name: Option<&str>,
) -> Uuid
pub fn generate_id( _name: &str, _database_type: Option<&DatabaseType>, _catalog_name: Option<&str>, _schema_name: Option<&str>, ) -> Uuid
Generate a UUIDv4 for a new table id.
Note: params are retained for backward-compatibility with previous deterministic-v5 API.