473,385 Members | 1,907 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,385 software developers and data experts.

inheritance help

I'm trying some experiments with PostgreSQL 7.3.4 with inheritance.

What I read is that if you implement triggers on a parent table, those
same triggers won't fire if you add records to a child table. However,
I tried it, and they did indeed fire, and worked perfectly. Same
sources said that indexes (indices??) wouldn't work right. Is that true?

What I'm trying to do is make the primary key id field reside in a base
table, which basically all the tables inherit. That way every row in
the database gets a unique id, and I only have to implement the key,
and the mod time/user creation time/user fields once.

I'm just wondering if anyone has been down the road with this, and can
tell me what might be wrong with this kind of a structure.

TIA

Jim McNeely
New Century Data
ji*@newcenturydata.com
http://www.newcenturydata.com
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #1
1 1411

Here's the way I handle it - and it works in other DBs as well:

create sequence objects;

create table X (object_id int8 not null default nextval('objects') primary
key, ......)

create table Y (object_id int8 not null default nextval('objects') primary
key, .......)

create table lastmods (object int8 not null, created_by int8, created_date
timestamp, last_modified_by int8, last_modified_date int8);

You can use object as a foreign key to all of your tables. Unfortunately,
unless you add several triggers and another table, you can't get foreign
key constraints.

Jon

On Tue, 25 Nov 2003, Jim McNeely wrote:
I'm trying some experiments with PostgreSQL 7.3.4 with inheritance.

What I read is that if you implement triggers on a parent table, those
same triggers won't fire if you add records to a child table. However,
I tried it, and they did indeed fire, and worked perfectly. Same
sources said that indexes (indices??) wouldn't work right. Is that true?

What I'm trying to do is make the primary key id field reside in a base
table, which basically all the tables inherit. That way every row in
the database gets a unique id, and I only have to implement the key,
and the mod time/user creation time/user fields once.

I'm just wondering if anyone has been down the road with this, and can
tell me what might be wrong with this kind of a structure.

TIA

Jim McNeely
New Century Data
ji*@newcenturydata.com
http://www.newcenturydata.com
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #2

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

Similar topics

6
by: Brian Jones | last post by:
I'm sure the solution may be obvious, but this problem is driving me mad. The following is my code: class a(object): mastervar = def __init__(self): print 'called a'
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
3
by: majid | last post by:
How can i write classes with multiple inheritance
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
2
by: Kevin Newman | last post by:
I have been playing around with a couple of ways to add inheritance to a JavaScript singleton pattern. As far as I'm aware, using an anonymous constructor to create a singleton does not allow any...
23
by: Dave Rahardja | last post by:
Since C++ is missing the "interface" concept present in Java, I've been using the following pattern to simulate its behavior: class Interface0 { public: virtual void fn0() = 0; };
3
by: Jess | last post by:
Hello, I've been reading Effective C++ about multiple inheritance, but I still have a few questions. Can someone give me some help please? First, it is said that if virtual inheritance is...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.