- Moderator
- #1
So... I have a couple of tables (simplified view here)
This would normally represent a one-to-many... where one Document would have multiple Pages. However, because of the way the importer worked, every page got its own Document and File.
... It *Should* look like this:
So, I'm trying to figure this out. It's about 28,000 lines I have to go through. Essentially, I need to turn a one-to-one table association into a one-to-many, updating the Documents table pointing to the first occurrence of the project in the Files table, and logically deleting (by updating the status) in the Files table to logically delete it so it doesn't display with no documents inside of it (since the documents will have been "moved" to point to the proper Files header.
Thank you in advance for pointing me in the right direction!
--Greg
Just my $.02
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg
Code:
Documents table (The "Documents" table is the "pages" in the "files" table)
DocumentID File ID
1 1234
2 1235
3 1236
4 1237
5 1238
Files Table (The "Files" table is the header information)
FileID Field2 Status
1234 Project1 Active
1235 Project1 Active
1236 Project2 Active
1237 Project2 Active
1238 Project3 Active
This would normally represent a one-to-many... where one Document would have multiple Pages. However, because of the way the importer worked, every page got its own Document and File.
... It *Should* look like this:
Code:
Documents table (The "Documents" table is the "pages" in the "files" table)
DocumentID File ID
1 1234 (Linked to the first occurrence of "Project1" in the files table)
2 1234 (Linked to the first occurrence of "Project1" in the files table)
3 1236 (Linked to the first occurrence of "Project2" in the files table)
4 1236 (Linked to the first occurrence of "Project2" in the files table)
5 1238 (Linked to the first, and only, occurrence of "Project3" in the files table)
Files Table (The "Files" table is the header information)
FileID Field2 Status
1234 Project1 Active
1235 Project1 Deleted (Now logically deleted, because no documents associated with it)
1236 Project2 Active
1237 Project2 Deleted (Now logically deleted, because no documents associated with it)
1238 Project3 Active
So, I'm trying to figure this out. It's about 28,000 lines I have to go through. Essentially, I need to turn a one-to-one table association into a one-to-many, updating the Documents table pointing to the first occurrence of the project in the Files table, and logically deleting (by updating the status) in the Files table to logically delete it so it doesn't display with no documents inside of it (since the documents will have been "moved" to point to the proper Files header.
Thank you in advance for pointing me in the right direction!
--Greg
Just my $.02
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg