Composite primary keys
Most tables in the CUSTOMERDB database have a column with the sole purpose of serving as a primary key (this type of primary key is sometimes referred to as a surrogate primary key or as an artificial primary key). However, some databases are not designed this way. Instead, a column in the database that is known to be unique across rows is used as the primary key. If there is no column whose value is not guaranteed to be unique across rows, then a combination of two or more columns is used as the table’s primary key. It is possible to map this kind of primary key to Jakarta Persistence entities by using a primary key class.
There is one table in the CUSTOMERDB database that does not have a surrogate primary key, this table is the ORDER_ITEMS
table. This table serves as a join table between the ORDERS
and ITEMS
tables. In addition to having foreign keys for these two tables, this table has an additional column called ITEM_QTY
, which stores the quantity...