HI,
let's say i have a tansaction table called TRANSACTION (transaction_id,amount,type,type_id)
Let's say a transaction can have multiple types: TYPE1, TYPE2 for example.
EACH type has his own definition and his own table.
Every transaction has a type that could be type1 or type2 that's why if the type is TYPE1 i want to make a referential integrity to the TYPE1_TABLE and if the type is TYPE2 i want to make a referential integrity to the TYPE2_TABLE.
IS IT POSSIBLE TO DO THAT???
I made a turn around to this problem by creating two tables:
- table TYPE1_TRANSACTION (type1_id,transaction_id)
- table TYPE2_TRANSACTION (type2_id,transaction_id)
But this does not seem so right for me ??
thx for any help
---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search 3 2540
Almost everything is possible if you accept to write your own triggers
and trigger functions. But there is no standard solution to this
problem.
There are of course inherited tables, but in the current
implementation, foreign key constraints doesn't work very well with
them (making them completly worthless IMO). That is going to change in
a future release according to the docs, but for now, table inheritance
is not the way to go in your case. Triggers are.
Regards
Erik let's say i have a tansaction table called TRANSACTION (transaction_id,amount,type,type_id)
Let's say a transaction can have multiple types: TYPE1, TYPE2 for example.
EACH type has his own definition and his own table.
Every transaction has a type that could be type1 or type2 that's why if the type is TYPE1 i want to make a referential integrity to the TYPE1_TABLE and if the type is TYPE2 i want to make a referential integrity to the TYPE2_TABLE.
IS IT POSSIBLE TO DO THAT???
I made a turn around to this problem by creating two tables: - table TYPE1_TRANSACTION (type1_id,transaction_id) - table TYPE2_TRANSACTION (type2_id,transaction_id)
But this does not seem so right for me ??
thx for any help
__________________________________________________ ______________________
Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
On Wednesday 08 October 2003 06:53, Nagib Abi Fadel wrote: HI,
let's say i have a tansaction table called TRANSACTION (transaction_id,amount,type,type_id)
Let's say a transaction can have multiple types: TYPE1, TYPE2 for example.
EACH type has his own definition and his own table.
Every transaction has a type that could be type1 or type2 that's why if the type is TYPE1 i want to make a referential integrity to the TYPE1_TABLE and if the type is TYPE2 i want to make a referential integrity to the TYPE2_TABLE.
IS IT POSSIBLE TO DO THAT???
You're looking at it the wrong way around, but in any case there are still
problems.
transaction_core(trans_id, trans_name, trans_type)
transaction_type1(tt1_core_id, tt1_extra1, tt1_extra2...)
transaction_type2(tt2_core_id, tt2_extra1, tt2_extra2...)
And have tt1_core reference trans_id (not the other way around). Do the same
for tt2_core and we can guarantee that the two transaction types refer to a
valid trans_id in transaction_core.
Now, what gets trickier is to specify that tt1_core should refer to a row in
transaction_core where trans_type=1.
Ideally, we could have a foreign-key to a view, or specify a constant in the
FK definition. We can't so you have to repeat the type field in
transaction_type1/2 and keep it fixed for every row.
HTH
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
--- Richard Huxton <de*@archonet.com> wrote: On Wednesday 08 October 2003 06:53, Nagib Abi Fadel wrote: HI,
let's say i have a tansaction table called TRANSACTION (transaction_id,amount,type,type_id)
Let's say a transaction can have multiple types: TYPE1, TYPE2 for example. EACH type has his own definition and his own
table. Every transaction has a type that could be type1
or type2 that's why if the type is TYPE1 i want to make a referential integrity to the TYPE1_TABLE and if the type is TYPE2 i want to make a referential integrity to the TYPE2_TABLE.
IS IT POSSIBLE TO DO THAT???
You're looking at it the wrong way around, but in any case there are still problems.
transaction_core(trans_id, trans_name, trans_type) transaction_type1(tt1_core_id, tt1_extra1, tt1_extra2...) transaction_type2(tt2_core_id, tt2_extra1, tt2_extra2...)
And have tt1_core reference trans_id (not the other way around). Do the same for tt2_core and we can guarantee that the two transaction types refer to a valid trans_id in transaction_core.
Now, what gets trickier is to specify that tt1_core should refer to a row in transaction_core where trans_type=1. Ideally, we could have a foreign-key to a view, or specify a constant in the FK definition. We can't so you have to repeat the type field in transaction_type1/2 and keep it fixed for every row.
HTH -- Richard Huxton Archonet Ltd
Actually a type1_id can have mutiple corresponding
transaction_ids (same thing for type2) that's why i
created the tables as follows:
create table transaction(
transaction_id serial P K,
amount int,...)
create table TABLE_TYPE1(
type1_id serial P K,
....
)
create table transaction_type1(
type1_id int,
transaction_id int
)
for example we can have the following possible entries
in table transaction_type1:
type1_id,transaction_id
100,101
100,102
100,103
200,312
200,313
200,314
200,315
Same thing for type 2.
I can also add that a transaction id can be of type1
or (exclusive) of type2 and never of two types at the
same time.
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rodney King |
last post by:
Hi,
I am supporting an application that was converted from ACCESS to SQL
Server 2000. My question focuses on two particuliar tables. The
parent table has 14000 rows while child table has over...
|
by: DB2 Novice |
last post by:
I am trying to use DB2 Control Centre (version 8.2) to load one flat
file into multiple tables. However, I don't see the options in Control
Centre that allows that.
Anyone knows how to do this?...
|
by: Heather |
last post by:
I am creating a database with a backend and frontend. The backend consists of a
Products table and many other tables. The products table in an .mdb file by
itself is over 2 meg. I thought about...
|
by: Koen |
last post by:
Hi all,
My application uses a lot of lookup tables.
I've splitted the frontend (forms, reports, etc) from the backend (data).
The database has around 10 different users.
The values in the...
|
by: dixie |
last post by:
If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click
event in Original.mde, is there an easy way of...
|
by: Krechting |
last post by:
Hi All,
I have a db with three tables which have a relationship.
The problem is that when I add a record to the ForAction table it
will automatically add a record to the Originator table but not...
|
by: Brian |
last post by:
I have a dataset containing 2 tables. I need to fill a datagrid using
data from both of these.
If I could create a SQL Statement to fill the datagrid, it would look
like this:
SELECT...
|
by: heyvinay |
last post by:
I have transaction table where the rows entered into the transaction
can come a result of changes that take place if four different tables.
So the situation is as follows:
Transaction Table...
|
by: knix |
last post by:
I have this access project consisting of multiple tables that are linked together in a relationship. I would like to migrate the consolidated information through appending in a datasheet form or...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |