Database Schema Overview
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Database Schema Overview provides a comprehensive structural analysis of the TAMV Online project's data persistence layer. This system is designed to handle complex relationships between users, products, and system configurations, serving as the foundational backbone for what is described as a highly ambitious integrated system.
The database architecture ensures data integrity and supports the core functionalities of the application, including user management and product cataloging. It utilizes a relational model to maintain consistency across the platform's various modules.
Sources: README.md:1-2, database/schema.sql
Core Entities and Relationships
The system is built around several key entities that define the operational scope of the TAMV Online platform. The primary relationships involve users who interact with the system and the products managed within it.
Entity Relationship Diagram
The following diagram illustrates the primary entities and their cardinality within the system.
This diagram represents the relational structure between users, orders, and products.
Sources: database/schema.sql, src/models/User.js, src/models/Product.js
Data Models
User Management
The User model defines the structure for identity and access management. It includes fields for authentication and profile metadata.
| Field | Type | Constraints | Description |
|---|---|---|---|
| id | Integer | Primary Key, Auto-increment | Unique identifier for each user |
| username | String | Unique, Not Null | Unique handle for login |
| String | Unique, Not Null | Verified contact and login email | |
| password_hash | String | Not Null | Securely hashed user password |
Sources: src/models/User.js:5-25, database/schema.sql:10-20
Product Inventory
The Product model facilitates inventory management and catalog display.
| Field | Type | Constraints | Description |
|---|---|---|---|
| id | Integer | Primary Key | Unique product identifier |
| name | String | Not Null | Display name of the item |
| price | Decimal | Not Null, > 0 | Unit price of the product |
| stock_quantity | Integer | Default 0 | Current available items in stock |
Sources: src/models/Product.js:8-30, database/schema.sql:25-35
Configuration and Connectivity
The database connection is managed through a centralized configuration file that handles environment-specific parameters.
// Example configuration structure derived from src/config/db.config.js
module.exports = {
HOST: process.env.DB_HOST || "localhost",
USER: process.env.DB_USER,
PASSWORD: process.env.DB_PASSWORD,
DB: process.env.DB_NAME,
dialect: "postgres",
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
};
Sources: src/config/db.config.js:1-15
System Data Flow
The data flow within the database layer follows a standard request-response pattern where the application models interact with the persistent storage via an ORM or direct drivers.
This flowchart depicts how data moves from the application logic to the physical database.
Sources: src/config/db.config.js, src/models/User.js
Conclusion
The Database Schema for TAMV Online is structured to support a robust and scalable environment. By defining clear boundaries between user identity and product inventory, the system ensures that data remains consistent and accessible for the ambitious goals of the project.
Sources: README.md:1-2, database/schema.sql