var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: postgresql linked / split table
I'd like to split a table into 2 different tables. I want to link them using the primary key. For example: primary key in table1 will link to primary key in table 2. I believe I would setup some kind of foreign key for this. I'm wondering how I can have the system automatically create the record in table2 when a record is added in table1. (it would be a 1 to 1 relationship)
Simply by using trigger or rules on a view.
I'm noob to postgresql so I'm not quite sure how to setup the trigger. This is what I'd like to do.
table1 - has all the main contact info
These tables have relavent info depending on the contact type in table1
If the contact type is "A" in table1, upon creating a new record I need a new record to be created in tablea.
If the contact type is "B" in table1, upon creating a new record I need a new record to be created in tableb.
I'm using pgadminIII as well as EMS to manage my postgresql database and can see how to add the trigger but I just don't know the programming in order to do it.
This might be a good place to use inheritance. I never thought this was much use until I read your post.
Inheritance lets you do exactly this.
Create table 1 with the common fields.
Create table A, inheriting table 1, along with additional fields.
Create table B, inheriting table 1, along with additional fields,
Simply insert the appropriate record into A, B, C, etc.
Only insert into table 1 if a record won't fit anywhere else.
If you want to see all of the records, just select * from table 1, and you will see all of the records from 1, A, B, C and so on.