This database schema demonstrates the Freudian structural model of the psyche (Id, Ego, and Superego) as an educational example of database design with primary and foreign key relationships.
Sigmund Freud's structural model divides the psyche into three components:
-
Id: The primitive, instinctual part of the mind containing sexual and aggressive drives. It operates on the pleasure principle, seeking immediate gratification.
-
Superego: The moral conscience incorporating societal rules and parental values. It strives for perfection and judges our behavior.
-
Ego: The realistic part that mediates between the desires of the id and the moral constraints of the superego. It operates on the reality principle, finding realistic ways to satisfy id's desires while considering superego's moral standards.
-
ID_COMPONENT
- Primary Key:
idComponentId - Represents primitive drives and instincts
- Types: Life Instinct, Death Instinct
- Primary Key:
-
SUPEREGO_COMPONENT
- Primary Key:
superegoComponentId - Represents moral rules and ideals
- Types: Conscience, Ego Ideal
- Primary Key:
-
EGO_DECISION
- Primary Key:
egoDecisionId - Foreign Keys:
idComponentId,superegoComponentId - Demonstrates the key relationship: The Ego mediates between Id and Superego
- Primary Key:
-
PSYCHOLOGICAL_CONFLICT
- Primary Key:
conflictId - Foreign Key:
egoDecisionId - Tracks conflicts between psychic components
- Primary Key:
-
DEFENSE_MECHANISM_CATALOG
- Primary Key:
mechanismId - Catalogs psychological defense mechanisms by maturity level
- Primary Key:
Each table has a unique identifier (primary key):
idComponentId,superegoComponentId,egoDecisionId, etc.
The EGO_DECISION table demonstrates complex relationships:
FOREIGN KEY (idComponentId) REFERENCES ID_COMPONENT(idComponentId)
FOREIGN KEY (superegoComponentId) REFERENCES SUPEREGO_COMPONENT(superegoComponentId)This structure mirrors the psychological theory where the ego must reference and mediate between id and superego components.
The schema includes various query examples:
- Basic Joins: View ego decisions with their associated id and superego components
- Conflict Analysis: Find and analyze psychological conflicts
- Defense Mechanisms: Analyze usage patterns of different coping mechanisms
- CTEs (Common Table Expressions): Complex queries for psychodynamic analysis
- Window Functions: Ranking and temporal pattern analysis
This schema serves as a practical example for learning:
- Database normalization
- Primary and foreign key relationships
- Complex joins across multiple tables
- Common Table Expressions (CTEs)
- Window functions
- CHECK constraints for data validation
- DEFAULT values and computed fields
-- Execute the freudian-psychology.tsql file in SQL Server Management Studio
-- The script will:
-- 1. Create all tables with appropriate constraints
-- 2. Insert sample data
-- 3. Provide example queries to explore the relationshipsWhile this example uses psychology concepts, the same pattern applies to many real-world scenarios:
- Order Processing: Orders reference both Products (what) and Customers (who)
- Project Management: Tasks reference both Projects (context) and Employees (who does it)
- Mediation Systems: Any scenario where one entity mediates between two others
The Id-Ego-Superego model provides an intuitive way to understand how foreign keys can represent complex relationships where one entity bridges or mediates between two others.