In my db I have a table type_of_action, fields code varchar, name
varchar, medical boolean. Two other tables refer to this table, one of
them to the medical rows, the other one to the none-medical rows. I
would like to make the reference with a view, like this:
create table type of action_type (
code varchar,
name varchar,
medical boolean
);
create view action_type_medical as select * from action_type
where medical=true;
create view action_type_non_medical as select * from action_type
where medical=false;
create table general_actions (
field1, field2, field_etc,
action_type varchar references action_type_non_medical(code)
);
create table medical_actions (
field1, field2, field_etc,
action_type varchar references action_type_medical(code)
);
But pg refuses this, can't create a reference to a view. I can now
create a trigger plus function that will do the check, but is there a
more elegant way? Thanks!
--
10:35-10:41
Fedora Core release 2 (Tettnang) Linux 2.6.6-1.435
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match 4 2225
On Wed, 16 Jun 2004, Joolz wrote: In my db I have a table type_of_action, fields code varchar, name varchar, medical boolean. Two other tables refer to this table, one of them to the medical rows, the other one to the none-medical rows. I would like to make the reference with a view, like this:
create table type of action_type ( code varchar, name varchar, medical boolean );
create view action_type_medical as select * from action_type where medical=true; create view action_type_non_medical as select * from action_type where medical=false;
create table general_actions ( field1, field2, field_etc, action_type varchar references action_type_non_medical(code) );
create table medical_actions ( field1, field2, field_etc, action_type varchar references action_type_medical(code) );
But pg refuses this, can't create a reference to a view. I can now create a trigger plus function that will do the check, but is there a more elegant way? Thanks!
Not really right now. Note, that to do foreign keys properly you need
triggers on action_type as well and those triggers need to take into
account the view conditions to determine what checks to do.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
On Wed, 16 Jun 2004, Joolz wrote: In my db I have a table type_of_action, fields code varchar, name varchar, medical boolean. Two other tables refer to this table, one of them to the medical rows, the other one to the none-medical rows. I would like to make the reference with a view, like this:
create table type of action_type ( code varchar, name varchar, medical boolean );
create view action_type_medical as select * from action_type where medical=true; create view action_type_non_medical as select * from action_type where medical=false;
create table general_actions ( field1, field2, field_etc, action_type varchar references action_type_non_medical(code) );
create table medical_actions ( field1, field2, field_etc, action_type varchar references action_type_medical(code) );
But pg refuses this, can't create a reference to a view. I can now create a trigger plus function that will do the check, but is there a more elegant way? Thanks!
Not really right now. Note, that to do foreign keys properly you need
triggers on action_type as well and those triggers need to take into
account the view conditions to determine what checks to do.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
> [Stephan Szabo schreef op 16-06-2004 07:57 -0700] On Wed, 16 Jun 2004, Joolz wrote:
In my db I have a table type_of_action, fields code varchar, name varchar, medical boolean. Two other tables refer to this table, one of them to the medical rows, the other one to the none-medical rows. I would like to make the reference with a view, like this:
create table type of action_type ( code varchar, name varchar, medical boolean );
create view action_type_medical as select * from action_type where medical=true; create view action_type_non_medical as select * from action_type where medical=false;
create table general_actions ( field1, field2, field_etc, action_type varchar references action_type_non_medical(code) );
create table medical_actions ( field1, field2, field_etc, action_type varchar references action_type_medical(code) );
But pg refuses this, can't create a reference to a view. I can now create a trigger plus function that will do the check, but is there a more elegant way? Thanks!
Not really right now. Note, that to do foreign keys properly you need triggers on action_type as well and those triggers need to take into account the view conditions to determine what checks to do.
Thanks for pointing that out. Considering this, it may be a better
idea after all to make two (physically) seperate tables after all.
After all, these are "only" domain tables, and I don't want the
reverse-update trigger to change any of my "real" data.
--
22:40-22:43
Fedora Core release 2 (Tettnang) Linux 2.6.6-1.435
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
> [Stephan Szabo schreef op 16-06-2004 07:57 -0700] On Wed, 16 Jun 2004, Joolz wrote:
In my db I have a table type_of_action, fields code varchar, name varchar, medical boolean. Two other tables refer to this table, one of them to the medical rows, the other one to the none-medical rows. I would like to make the reference with a view, like this:
create table type of action_type ( code varchar, name varchar, medical boolean );
create view action_type_medical as select * from action_type where medical=true; create view action_type_non_medical as select * from action_type where medical=false;
create table general_actions ( field1, field2, field_etc, action_type varchar references action_type_non_medical(code) );
create table medical_actions ( field1, field2, field_etc, action_type varchar references action_type_medical(code) );
But pg refuses this, can't create a reference to a view. I can now create a trigger plus function that will do the check, but is there a more elegant way? Thanks!
Not really right now. Note, that to do foreign keys properly you need triggers on action_type as well and those triggers need to take into account the view conditions to determine what checks to do.
Thanks for pointing that out. Considering this, it may be a better
idea after all to make two (physically) seperate tables after all.
After all, these are "only" domain tables, and I don't want the
reverse-update trigger to change any of my "real" data.
--
22:40-22:43
Fedora Core release 2 (Tettnang) Linux 2.6.6-1.435
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: NewToDotNet |
last post by:
I am getting "Object reference not set to an instance of an object. " when I
attempt to open a C# windows service class in design view, although I was
able to initially create the service and open...
|
by: Le, Thanh-Nhan |
last post by:
Hi,
How can I remove a reference to a COM Dll? I want to add reference to new
version of this dll.
Thanks
Nhan
|
by: Patrick |
last post by:
This is a C# post.
I'm using VB.NET to create an add-in for the Google Sidebar, and have
implemented the OnDetailsView method.
NOTE : I've come across this same problem (error message) even in...
|
by: Jeff |
last post by:
I'm getting an Object Reference error before I even run my app, and
I'm not sure where to look to find the cause. I'd appreciate your
help.
When I open my Windows Application project, the...
|
by: Joolz |
last post by:
In my db I have a table type_of_action, fields code varchar, name
varchar, medical boolean. Two other tables refer to this table, one of
them to the medical rows, the other one to the none-medical...
|
by: Laura K |
last post by:
Hi.
I am trying to put a drop down in a repeater. I had this working in
dreamweaver but now I am trying to transfer it into VS. I am obviously
missing something. I am getting the following...
|
by: Jim Langston |
last post by:
I remember there was a thread a while back that was talking about using the
return value of a function as a reference where I had thought the reference
would become invalidated because it was a...
|
by: Turin |
last post by:
Dear all;
As far as I understand the idea behind getter methods, it is used to
make sure that private memers of a class is returned appropriately to
the calling object.
However, if all I am...
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
| |