MSDN Documentation

Core Platform - Data Models

Understanding Core Data Models

This section details the fundamental data models used across the core platform. These models represent the building blocks for various services and functionalities, ensuring consistency and interoperability.

Entity-Relationship Model

Our primary data modeling approach is based on the Entity-Relationship (ER) model. This involves defining:

Common Core Entities

Here are some of the most frequently used core entities:

User Entity

Attribute Type Description Constraints
userId UUID Unique identifier for the user. Primary Key, Not Null
username String User's chosen username for login. Unique, Not Null, Min Length 3
email String User's email address for communication. Unique, Not Null, Valid Email Format
createdAt DateTime Timestamp when the user account was created. Not Null, Default: Current Timestamp
lastLogin DateTime Timestamp of the last successful login. Nullable

Product Entity

Attribute Type Description Constraints
productId UUID Unique identifier for the product. Primary Key, Not Null
name String Name of the product. Not Null, Max Length 255
description Text Detailed description of the product. Nullable
price Decimal Price of the product. Not Null, Precision(10, 2), Non-Negative
stockQuantity Integer Current quantity of the product in stock. Not Null, Non-Negative

Relationships

Relationships define how entities are connected. We primarily use one-to-many and many-to-many relationships.

Example: Order and OrderItem

An Order entity would typically include:


interface Order {
  orderId: UUID;
  userId: UUID; // Foreign key to User
  orderDate: DateTime;
  totalAmount: Decimal;
  status: OrderStatus; // e.g., PENDING, SHIPPED, DELIVERED
  // ... other order details
}
                

And an OrderItem entity to manage the many-to-many relationship with Product:


interface OrderItem {
  orderItemId: UUID;
  orderId: UUID; // Foreign key to Order
  productId: UUID; // Foreign key to Product
  quantity: Integer;
  unitPrice: Decimal;
  // ... other item-specific details
}
                

Data Types and Constraints

We utilize a standardized set of data types for consistency. Common types include:

Constraints such as Not Null, Unique, Min Length, Max Length, and range checks are applied to ensure data integrity.

Data Validation

All data submitted to the core platform undergoes rigorous validation based on these defined models and constraints. This ensures that only accurate and well-formed data enters the system.