类到表的映射 将超类的属性下移()日 在这种方法中,每个子类对应的数据 库表中既包含该子类中的属性,也包含该 子类所继承的属性。超类不映射为数据库 表,这样就减少了数据库表的数量 11
11 在这种方法中,每个子类对应的数据 库表中既包含该子类中的属性,也包含该 子类所继承的属性。超类不映射为数据库 表,这样就减少了数据库表的数量 类到表的映射 将超类的属性下移(1)
将超类的属性下移(2) Employee name taxpayerNumber A Pilot FlightAttendant flightRating Employee table pilotID name taxpay erNumber flightRating FlightAttendant table flightAttendID name taxpayerNumber 12
12 pilotID name taxpayerNumber flightRating Employee table flightAttendID name taxpayerNumber FlightAttendant table Employee name taxpayerNumber Pilot flightRating FlightAttendant 将超类的属性下移(2)
类到表的映射 :将超类的属性下移(3) 这种方法的优点: ■能容易地生成报表,因为所需的有关各类的所 有数据都存储在同一张表中 这种方法的缺点: ■当修改某个类时,必须修改它自己对应的表和 所有子类对应的表 ■很难在支持多个角色的同时仍维护数据完整性 13
13 这种方法的优点: ◼ 能容易地生成报表,因为所需的有关各类的所 有数据都存储在同一张表中 这种方法的缺点: ◼ 当修改某个类时,必须修改它自己对应的表和 所有子类对应的表 ◼ 很难在支持多个角色的同时仍维护数据完整性 类到表的映射 将超类的属性下移(3)
类到表的映射 将子类的属性上移(1) 在使用这种方法时,需将所有子类的属性都 存放在超类所对应的数据库表中。换言之,一个 完整的类层次结构只映射为一张数据库表,而层 次结构中所有类的所有属性都存储在这张数据库 表中。这样,就避免了将众多的子类映射为数据 库表,从而减少了数据库表的数量 14
14 在使用这种方法时,需将所有子类的属性都 存放在超类所对应的数据库表中。换言之,一个 完整的类层次结构只映射为一张数据库表,而层 次结构中所有类的所有属性都存储在这张数据库 表中。这样,就避免了将众多的子类映射为数据 库表,从而减少了数据库表的数量 类到表的映射 将子类的属性上移 (1)
类到表的映射 :将子类的属性上移(2) Employee name taxpayerNumber A Pilot FlightAttendant flight Rating Employee table employeelD taxpayer employee name Number Type flight Rating 15
15 employeeID name taxpayer Number employee Type flight Rating Employee table Employee name taxpayerNumber Pilot flightRating FlightAttendant 类到表的映射 将子类的属性上移 (2)