Current location - Education and Training Encyclopedia - Graduation thesis - Is there a one-to-one correspondence between entity database classes and tables?
Is there a one-to-one correspondence between entity database classes and tables?
1, the class diagram mainly shows the relationship between classes in the model.

2. There is a correspondence between the database table and the class to be persisted. Ordinary persistent classes, one class corresponds to a table, one attribute corresponds to a field, and data types also have corresponding relationships. According to the relationship between classes, there are inheritance, one-to-one, many-to-one, one-to-many, many-to-many and so on. There are different strategies to deal with the persistence of these relationships.

For example, inheritance is divided into multi-table inheritance and single-table inheritance; Many-to-one, add the primary key field of the associated class and add the foreign key in the associated class; One-to-many is a many-to-one relationship in opposite directions, such as two tables, where A is many-to-one relative to B and B is one-to-many relative to A; One-to-one is similar to one-to-many, except that the primary key of the master table is also unique in the slave table; Many-to-many relationship, the relationship between two tables will be stored in a new table, and the primary keys of both tables will be stored.