HI,
let's say i have a tansaction table called TRANSACTION (transaction_id ,amount,type,ty pe_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_TRANSACTI ON (type1_id,trans action_id)
- table TYPE2_TRANSACTI ON (type2_id,trans action_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 2574
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,ty pe_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_TRANSACTI ON (type1_id,trans action_id) - table TYPE2_TRANSACTI ON (type2_id,trans action_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,ty pe_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_cor e(trans_id, trans_name, trans_type)
transaction_typ e1(tt1_core_id, tt1_extra1, tt1_extra2...)
transaction_typ e2(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_cor e.
Now, what gets trickier is to specify that tt1_core should refer to a row in
transaction_cor e 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_typ e1/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.c om> 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,ty pe_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_cor e(trans_id, trans_name, trans_type) transaction_typ e1(tt1_core_id, tt1_extra1, tt1_extra2...) transaction_typ e2(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_cor e.
Now, what gets trickier is to specify that tt1_core should refer to a row in transaction_cor e 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_typ e1/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_typ e1(
type1_id int,
transaction_id int
)
for example we can have the following possible entries
in table transaction_typ e1:
type1_id,transa ction_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 YourEmailAddres sHere" to ma*******@postg resql.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 9 million rows.
Referential integrity is set up between the two tables. The parent
table has a composite primary key of:
CustomerId (int)
LocationId (int)
ProductId (int)
|
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?
DB2 Novice
|
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 putting the products table in a file by
itself and all the other tables in another file. I anticipate there will be a
need for changes in the other tables and since communication is over the
internet, having the products table in a different file...
|
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 lookup tables are not likely to change.
Question 1: Should I include them in the backend (with rest of data) or the
frontend?
|
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 coding it without naming
every single table in Original.mde. I am looking for a way of updating a
database on site without needing to access the database window and import
the existing tables into a new empty database.
dixie
| |
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 to
the RFI table.
I do not want access to add a record to the Originator table but
only to the ForAction table. Is this possible?
|
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 fields.fieldname, fieldvalues.value FROM fields, fieldvalues
I am having trouble finding documentation explaining how to populate
|
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
-TranId
-Calc Amount
Table 1 (the amount is inserted into the transaction table)
- Tb1Id
|
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 importing the gathered information . Can anyone please give solutions with my problem?
Can I make a datasheet form (consisting fields from multiple tables that are linked together with relationships) in ms access which I could paste append or insert...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |