Type Inheritance Suppose that we have the following type definition for people: create type Person (name varchar(20), address varchar(20)) Using inheritance to define the student and teacher types create type Student under Person (degree varchar(20), department varchar(20)) create type Teacher under Person (salary integer, department varchar(20)) Subtypes can redefine methods by using overriding method in place of method in the method declaration Database System Concepts-6th Edition 22.12 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 22.12 ©Silberschatz, Korth and Sudarshan th Edition Type Inheritance Suppose that we have the following type definition for people: create type Person (name varchar(20), address varchar(20)) Using inheritance to define the student and teacher types create type Student under Person (degree varchar(20), department varchar(20)) create type Teacher under Person (salary integer, department varchar(20)) Subtypes can redefine methods by using overriding method in place of method in the method declaration
Multiple Type Inheritance SQL:1999 and SQL:2003 do not support multiple inheritance If our type system supports multiple inheritance,we can define a type for teaching assistant as follows: create type Teaching Assistant under Student,Teacher To avoid a conflict between the two occurrences of department we can rename them create type Teaching Assistant under Student with (department as student dept ) Teacher with (department as teacherdept Each value must have a most-specific type Database System Concepts-6th Edition 22.13 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 22.13 ©Silberschatz, Korth and Sudarshan th Edition Multiple Type Inheritance SQL:1999 and SQL:2003 do not support multiple inheritance If our type system supports multiple inheritance, we can define a type for teaching assistant as follows: create type Teaching Assistant under Student, Teacher To avoid a conflict between the two occurrences of department we can rename them create type Teaching Assistant under Student with (department as student_dept ), Teacher with (department as teacher_dept ) Each value must have a most-specific type