官术网_书友最值得收藏!

Entity relationships

In the previous section, we saw how to retrieve, insert, update, and delete single entities from the database. Entities are rarely isolated; in the vast majority of cases they are related to other entities.

Entities can have one-to-one, one-to-many, many-to-one, and many-to-many relationships.

In the CustomerDB database, for example, there is a one-to-one relationship between the LOGIN_INFO and the CUSTOMERS tables. This means that each customer has exactly one corresponding row in the login info table. There is also a one-to-many relationship between the CUSTOMERS table and the ORDERS table. This is because a customer can place many orders, but each order belongs only to a single customer. Additionally, there is a many-to-many relationships between the ORDERS table and the ITEMS table. This is because an order can contain many items and an item can be on many orders.

In the next few sections, we will discuss how to establish relationships between JPA entities.

主站蜘蛛池模板: 太仆寺旗| 庆阳市| 衢州市| 博爱县| 专栏| 嘉义县| 车致| 岳西县| 兴隆县| 遵义县| 皮山县| 扶余县| 新宾| 郓城县| 玛纳斯县| 金溪县| 湘阴县| 台中市| 额敏县| 恩施市| 佛学| 新密市| 高州市| 高雄市| 汤阴县| 古浪县| 得荣县| 岐山县| 荃湾区| 松桃| 宜兰县| 淄博市| 江都市| 清涧县| 林西县| 伊金霍洛旗| 连城县| 十堰市| 新宁县| 中江县| 新河县|