Home » SQL & PL/SQL » SQL & PL/SQL » Inheritance!!!!!!
Inheritance!!!!!! [message #194882] Mon, 25 September 2006 20:36 Go to next message
ntttuyen
Messages: 2
Registered: September 2006
Junior Member
Dear friends!!
I am working with object relational features in Oracle and have these problem. Please help me! Thanks in advance!
I have 3 tables
person_tab(id, name)
employee_tab(id, name, salary, manager)
student_tab(id, name, gpa)

I create 3 object types that have inheritance relationships as following:

person_type(id, name)
employee_type(id, name, salary, manager) inherits person_type
student_type(id, name, gpa) inherits person_type

then I create 3 object views based on these 3 types and these views also have inheritance relationships
person_view(id, name) ~ person_tab
employee_view(id, name, salary, manager) inherits person_view~ employee_tab
student_view(id, name, gpa) inherits person_view ~ student_tab

How can I query person_view for objects that have salary > 5000$ or gpa>4.0?
Please help me!

I've already tried TREAT() function but in my case there are many predicates which place constrainsts on different subtypes, It's very difficult to treat each type separately. Thanks for any tip!

[Updated on: Mon, 25 September 2006 23:40]

Report message to a moderator

Re: Inheritance!!!!!! [message #194918 is a reply to message #194882] Tue, 26 September 2006 03:03 Go to previous message
vijayanarayanan
Messages: 11
Registered: September 2006
Location: chennai
Junior Member
person_type(id, name)
employee_type(id, name, salary, manager) inherits person_type
student_type(id, name, gpa) inherits person_type


SELECT P.ID,P.NAME
FROM PERSON_TYPE P,EMPLOYEE_TYPE E,STUDENT_TYPE S
WHERE P.ID = E.ID AND P.NAME = E.NAME
AND E..ID = S.ID AND E..NAME = S.NAME
AND E.SALARY > 5000
AND GPA > (VALUE);
Previous Topic: Check this code !
Next Topic: populate table
Goto Forum:
  


Current Time: Sat Dec 10 15:05:00 CST 2016

Total time taken to generate the page: 0.12903 seconds