In this module, we will explore One-to-One relationships and build a complete multi-tier Java EE web application using the MVC design pattern.

11.1. One-to-One constraints & MVC Portal Architecture

Definition: One-to-One connects two tables. The MVC pattern separates applications into Model, View, and Controller layers.

Core Working Principles:

// Enforcing unique constraint in child Profile
@OneToOne
@JoinColumn(name = "user_id", unique = true)
User user;
5-Marks Exam Scoring Points
  • One-to-One maps a single record in one table to exactly one record in another.
  • unique=true on @JoinColumn is mandatory to enforce the 1-to-1 relationship in the database.
  • MVC separates business logic from views, improving maintainability.