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 UML diagram shows the relationship between the tables:

The following are the steps for creating a new table:

  1. First, we create the Owner entity and repository in the domain package. The Owner entity and repository are created similarly to what we did with 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.0 and React 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.