473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Heritage

Hi everyone. Im having a problem with heritage. The situation is the following:
I have two tables, tbl_everyone and tbl_employees. tbl_employees
inherits from tbl_everyone.
In tbl_everyone, i store some information about everyone who is
related with the place where i work: Name, ID (PK), Birth Date,
Adress...
Then, in tbl_employees i have aditional information, like area, position, etc.
The problem appears when i have someone in tbl_everyone that becomes
an employee. What do i have to do ? Consider that ID in tbl_everyone
is used in auxiliar tables, so i cannot easily delete the person in
tbl_everyone and insert it again in tbl_employees...
Thanks in advance
Sebastian Davancens

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
2 1449
On Wed, 2004-09-08 at 14:27, Sebastian Davancens wrote:
Hi everyone. Im having a problem with heritage.
.... whatever that might be...
The situation is the following:
I have two tables, tbl_everyone and tbl_employees. tbl_employees
inherits from tbl_everyone.
In tbl_everyone, i store some information about everyone who is
related with the place where i work: Name, ID (PK), Birth Date,
Adress...
Then, in tbl_employees i have aditional information, like area, position, etc.
The problem appears when i have someone in tbl_everyone that becomes
an employee. What do i have to do ? Consider that ID in tbl_everyone
is used in auxiliar tables, so i cannot easily delete the person in
tbl_everyone and insert it again in tbl_employees...


Rather than inheriting, tbl_employees could be a separate table that
holds only the additional information and it should have a foreign key
reference to tbl_everyone. When someone becomes an employee, create a
row in tbl_employees with the extra information.

Create a View that combines tbl_employees with tbl_everyone to return
the information that your inheriting table would have given you.
Alternatively, create a separate index of keys to the hierarchy and use
it as the target for foreign key references. Use triggers to keep it up
to date.
--
Oliver Elphick ol**@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Put on the whole armor of God, that ye may be able to
stand against the wiles of the devil."
Ephesians 6:11
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2
Sebastian Davancens wrote:
Hi everyone. Im having a problem with heritage. The situation is the following:
I have two tables, tbl_everyone and tbl_employees. tbl_employees
inherits from tbl_everyone.
In tbl_everyone, i store some information about everyone who is
related with the place where i work: Name, ID (PK), Birth Date,
Adress...
Then, in tbl_employees i have aditional information, like area, position, etc.
The problem appears when i have someone in tbl_everyone that becomes
an employee. What do i have to do ? Consider that ID in tbl_everyone
is used in auxiliar tables, so i cannot easily delete the person in
tbl_everyone and insert it again in tbl_employees...


Have you tried deferred constraints, eg:

BEGIN;
SET CONSTRAINTS ALL DEFERRED;
DELETE ...;
INSERT ...;
END;

I've haven't had chance to test this, but I think this could
be what you're looking for.

--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
by: Wim Vanhoof | last post by:
Dear all, I would like to announce that the department of computer science of the University of Namur, Belgium, is seeking a post-doctoral researcher for a one-year fellowship in the area of ...
23
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since...
1
by: Vincent M. | last post by:
Hello, I am trying to a onMouseover to the change the background of <td>s when the mouse is on, the problem is that does not work when we put the content of these <td>s inside another table...
0
by: stephane parenton | last post by:
hi everyone.... i'm having a slight problem understanding something.... I've bought a book about programming postgres, and there's a part concerning heritage.... so as i need to implement something...
0
by: stephane parenton | last post by:
Hi everyone, I'm trying to understand the heritage with postgres.... I have a table called iface with (Physik macaddr UNIQUE, logik cidr) and another table called komputer with (OS...
15
by: bugzilla | last post by:
hi,all, I have a C++ program need to convert to c language to be used in a emabedded system. the problem is that the original code was writtern in C++ language with Parent class and some child...
0
by: Davidoff | last post by:
Bonjour, je voudrais réaliser un héritage d'un type complexe avec attributs <xs:complexType name="A"> <xs:attribute name="day"/> </xs:complexType> puis deux types dérivés :
5
by: Alexandre Badez | last post by:
Hye, I'm developing a little app, and I want to make multi heritage. My problem is that my both parent do have __slots__ define. So I've got something like: class foo(object): __slots__ = ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.