Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Duplicating a record with multiple sub-records

Author  Topic 

barak123
Starting Member

1 Post

Posted - 2002-10-29 : 03:54:47
Hi! I was wondering if anyone can help me with the following problem:

I have several tables that store data related to an html page.
The first table, called "page_general", holds the name of the html page and its general attributes.

The second table, called "page_elements", holds the page's elements. For each element within a page, a new row is created and a new elementID is generated.

Finally, I have a third table called "page_elementAttributes" which contains a pageID, elementID and an attributeID. There can be several rows of attributes per element.

Basically, the "page_general" table has a one-to-many relationship with the "page_elements" table, and the "page_elements" table has a one-to-many relationship with the "page_elementAttributes" table.

Now, my problem is that I need to take a page with all its related elements (and their attributes) and copy all that data into a new page (that will have its own ID).

Is there any easy way to do this? I'd really appreciate any help you can offer.

Thanks,

Barak

mr_mist
Grunnio

1870 Posts

Posted - 2002-10-29 : 04:01:45
To be honest I don't think that duplicating the data is the way to go. I think you should have a separate field linking off to another table that contains the IDs of all the pages that use the same set of data, if you see what I mean. This seems a lot cleaner to me than copying everything.

Go to Top of Page

jeroena
Yak Posting Veteran

76 Posts

Posted - 2002-10-29 : 05:22:49
Hi...

I would make a stored procedure (stp_copy_page or whatever) that does some selects and inserts in a transaction.

I see a lot on the forums, that people judge about the design in question without knowing anything about the application requirements or environment. Without given a solution to the problem. Maybe barak123 has users who want to build a new page with another one as a starting point. You will have to make a copy!

BTW, barak, are you a Microsoft developer currently working on MS Frontpage?? LOL

Jeroen.



Go to Top of Page
   

- Advertisement -