Relationships between tables

Next, we create a new table called owner that has a one-to-many relationship with the car table. The owner can own multiple cars, but a car can have only one owner. The following Unified Modeling Language (UML) diagram shows the relationship between the tables:

The following are the steps to create a new table:

  1. First, we create the Owner entity and repository in the domain package. The Owner entity and repository are created in a similar way to the Car class. The following is the source code of the Owner entity class and OwnerRepository:
      // Owner.java      package com.packt.cardatabase.domain;  import javax.persistence.Entity; ...

Get Hands-On Full Stack Development with Spring Boot 2 and React - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.