Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting rows into multiple tables

Status
Not open for further replies.

amcg

Programmer
Jan 25, 2002
26
IE
Hello.

I've got a database which has the following general structure:

Customer_Details - stores general customer information, including a customer_ID

Customer_Purchase_Link - stores customer_IDs and purchase_IDs so one can keep track of each customer's purchase history.

Various other tables, all using purchase_ID as a foreign key.

In summary: [Customer_Details]-[Customer_Purchase_Link]- [...various other tables...]

When a new customer is added to the system, is there an easy way to automatically generate a record in the link table as well as corresponding entries in all the other tables?

Similarly, when a new purchase is added to the system and linked to a certain customer, is there an easy way of making entries for this purchase in all the other tables too?

I've designed similar databases before and they work very efficiently apart from this point. In general I've just put code behind the various "add purchase" (or whatever) buttons to add all the records.

It occurs to me that there must be a better way, such as putting code behind a table so that when a record is added to that table, records are added to other tables using the same ID.

Thanks in advance for any help.
 
Apologies for the double post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top