Design of DB which stores files and has a history.

We have a very simple requirement: Object 'A' might have several attachments. Attachment means either a physical file stored in the DB (max 10 MB) or URL pointing to a file in the web/network/anywhere. In case an attachment is a file,
that file cannot be updated. Attachments might be deleted.
We started with the following simple DB schema:
Then we realized that we need to have a History table for the attachments to track changes in the FILE_NAME and URL columns. (The file stored in the ATTACHMENT column cannot be changed, but its name can be changed). The whole row in the
attachments table might be deleted. So the initial thought was to create this table:
However, this design has one drawback – the same file is duplicated (stored in several places). Since the file once inserted, can never be changed, there is no point to store it in the history table every time its name was changed.
Option 1.
My idea is to leave this schema unchanged, but to change the logic a bit. Every
update in the ATTACHMENTS table should trigger copying only of ATTACHMENT_PID, TABLE_A_ID, FILE_NAME and URL fields from that table to ATTACHMENTS_HIST. The ATTCHMENT field is not copied. When the row is
deleted from ATTACHMENTS table, then all fields including the file itself are copied to the ATTACHMENTS_HIST table. As a result of this, we store the file only in one place.
See option 2 in the next message..
Alexey

Option 2.
Split ATTACHMENTS table into 2 tables (ATTACHMENTS_META and ATTACHMENTS_DATA) to store the file in a separate table. Files will never be deleted. As a result, we can safely remove ATTACMENT column from ATTACHMENTS_HIST table. We don’t
need it anymore because ATTACHMENT_ID will always point to the file:
Here ATTACHMENTS_DATA table has FK:
CONSTRAINT FK_ATTACHMENTS_DATA__ATTACHMENTS_META
FOREIGN KEY (ATTACHMENT_ID)
REFERENCES dbo.ATTACHMENTS_META
(ATTACHMENT_ID)     
Because of this, the relationship between ATTACHMENTS_META table and ATTACHMENTS_DATA table is 1:1.
At first blush the idea possesses common sense, but on closer examination it fails because we cannot delete a row from ATTACHMENTS_META. Why? Because it is a Master table and ATTACHMENTS_DATA is a Details table. We cannot leave the detail
without master. (The data in the ATTACHMENTS_DATA never deleted.)
What if we swap Master and Details table? I mean if ATTACHMENTS_DATA is Master and ATTACHMENTS_META is Details. Well, in this case we can delete a row from ATTACHMENTS_META table and leave the corresponding file in the ATTACHMENTS_DATA.
So it seems that it solves the problem.
However, it raises another issue. Do you remember that instead of a file we can have URL? URL stored in the ATTACHMENTS_META table which is Details table in this case. And we cannot create a row in that table until we create a row in the
Master table. But we don’t need a file for URL attachment. So this solution will not work.
Eventually, option 2 has the following solution:
Here ATTACHMENT_DATA table is Master and ATTACHMENT_META table is Details. Optional (null-able)   ATTACHMENT_DATA_ID column was added to ATTACHMENT_META table. It allows splitting PK and FK in this table. 
Now the question: Which option (1 or 2) would you prefer? Can you suggest option 3?
Option 1
+ There are only 3 tables
- File is copied from ATTACHMENTS to ATTACHMENTS_HIST table before deleting from ATTACHMENTS.
Option 2
+ File is not copied.
- There are 4 tables.
- Relationship between ATTACHMENTS_DATA table and ATTACHMENTS_META table is 1:n which actually does not reflect the reality.
Thank you in advance.
Alexey

Similar Messages

  • How to repair my macbook pro when i had delete the app store file and know it telling that appstore file has been damage or incomplete and i had the version 10.6.8

    how to repair my macbook pro when i had delete the app store file and know it telling that appstore file has been damage or incomplete and i had the version 10.6.8

    so is their is any way that i can solve this matter

  • Table Names which stores GRN and GRIR Details of a PO

    Hi Friends,
    I want table names which stores GRN and GRIR details of a PO.
    Thanks in advance
    Expecting ur answers,
    Cheers;-)
    R.Kripa.

    Hi,
    From MKPF get the gr for PO.
    if you see VGART = 'WE' and BLART = 'WE' then you get all MBLNR s GR related PO's. and using those go to MSEG table and get MSEG-EBELN and MSEG-EBELP
    this is the flow...
    MKPF to it_mkpf where VGART = 'WE' and BLART = 'WE'.
    from
    MSEG get EBELN,EBELP for all entries of MKPF and get PO's corresponding GR's
    i hope it is clear...
    Regards
    vijay

  • Great Video Editor That opens m4v files and has WMM effects. not imovie

    So like the title says, i need a good video editor that opens up m4v files and has similar effects to windows movie maker. I accidentely removed iMovie from my computer and now i have nothing. Please don't suggest some really expense/advanced editors. Thanks!

    Why don't you just use your install disk(s) and reinstall iMovie?

  • I keep losing the line at the top of the page which includes "file,edit veiw,bookmarks,history,help etc" I can get it back by pressing lt+F8 but it goes again when i press another key.how can I restore this permanently

    I have lsot the line in the toolbar spaces which include "file,edie,veiw,bookmarks,history,help"etc.Ican get it back by pressing Alt+F8 but it goes when I press any other key.How can I restore this permanently

    Thanks for the information, is this a windows 7 problem?

  • The File "(file name)" is an iTunes Store File and can't be burned to MP3cd

    I am using the most recent updates to OS 10.4.8 and iTunes 7. I am getting this error stating that iTunes Store Files, which are also protected AAC files, can neither be burned to MP3 CD or converted into MP3 files. I also tried using Roxio Toast, most recent version, which converts the files to QuickTime AIFF files, which will not even play in QuickTime. I did not have this problem with older versions of iTunes. It is only songs purchased from iTunes Store that have this problem.
    Any suggestions?

    Which version of Toast 6 are you using? Roxio made the change with the 6.1 update to "fix" Toast to no longer burn purchased iTMS content.
    http://www.roxio.com/enu/support/toast/version_history6.html
    "Following discussions with Apple, this version will no longer allow customers to create audio CDs, audio DVDs, or export audio to their hard drive using purchased iTunes music store content."
    If your CD version is previous to 6.1 and you updated it after the fact, you could try deleting it and reinstalling it and this time NOT updating it and see if you can now burn the iTMS songs.
    Patrick

  • What is this .DS Store file and why does it keep coming back?

    So a few weeks ago I noticed this .ds store hidden file showing up on my desktop of my MacBook Pro, I deleted it, so it's over with right? WRONG!!! Could not have been more wrong. This file now shows up in every single folder I open on my computer. I've deleted it form the same folder numerous times only for it to reappear again and again and again. It's even showing up on my USB Flash Drives. I've reached a point where I'd rather throw this computer out the window then have to keep dealing with this insufferable file. Can someone please explain to me what the heck is going on? And more importanly on I can actually fix this problem so I DO NOT have to deal with it anymore? Any help is greatly appreciated.
    Side Note: I have already used a bunch of different programs and none have yet to work. Everyone keeps recommending TinkerTools and it doesn't do squat.

    This will explain the .ds store file. As you've found out there's one for every file. If you don't want to see those hidden files, don't display hidden files.
    To make hidden file hidden, bring up terminal, enter "defaults write com.apple.Finder AppleShowAllFiles NO" (don't type the quote marks), then force quit finder and relaunch it. If that doesn't work, change NO to FALSE. 

  • Table which Stores Program, and its source code

    Dear All,
    Can you please let me know the tables which stores program names,its variant, soruce code and related information.
    Appreciate your early help

    Hi,
    check this FM : SVRS_GET_REPS_FROM_OBJECT. you can get all the information about programs.
    code sample
    DATA :repos_tab_old      LIKE     abaptxt255 OCCURS 0 WITH HEADER LINE,
           trdir_tab_old      LIKE     trdir OCCURS 0 WITH HEADER LINE.
    DATA : object_name     LIKE     vrsd-objname,
           object_type     LIKE     vrsd-objtype,
           versno            LIKE     vrsd-versno,
           destination     LIKE     rfcdes-rfcdest.
           CALL FUNCTION 'SVRS_GET_REPS_FROM_OBJECT'
              EXPORTING
                object_name       = object_name
                object_type       = object_type
                versno            = versno
        DESTINATION       = ' '
              TABLES
                repos_tab         = repos_tab_old
                trdir_tab         = trdir_tab_old
             EXCEPTIONS
               no_version        = 1
               OTHERS            = 2
            IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
    Laxman

  • HT201263 While doing the restore the connect to Itunes image is still on my phone and has not shut off?  The Itunes "status" area now says "Processing File" and has said this for 15 mintues with no change. What do I do??? This is the second Restore I've a

    While doing the Restore the "connect to Itunes Image is still on my phone and has not shut off or changed since starting the REstore.  Now Itunes status bar says "Processing File" but has not changed or done anything for 15+ minutes.  What do I need to do?  Let it go or is it not working????  FYI, I tried to update to the 6.0.1 (I believe thats this update)

    This was the third Restore I've attempted today.... 'm not sure what all I did including unplugging and plugging it back in, and messing with tryign to select my phone vs. my husbands but it starting moving again.  It's now attempting to "back up" from ICloud... we'll see. Thanks

  • HT4796 i have successfully migrated the music but it just shows up in my files and has not updated my iTunes library which is still getting the music from iCloud and is not using the migrated files. Any ideas?

    I have successfully used windows migration software to move my music library from a PC to my MacBook Air.
    However the music files are just stored in my file system and have not updated my itunes files. Itunes is still getting the music down from icloud instead of using the music files.
    Any ideas?

    If you're using Windows Movie Maker and HP Photo to build slide shows, this is not an iPod touch issue (nor an iTunes issue), so I'd suggest you take up the problem on a web site that deals with Movie Maker or HP Photo issues. It's really not something we can help with in this forum.
    If you're building this slide show on your iPod, please post back and tell us what app(s) you're trying to use, and whether the iPod app on your iPod touch shows and plays your songs correctly. Knowing the specific model of iPod you have and the version of iOS it's running will probably also help.
    Regards.

  • How do back up deb files and has anyone tried andr...

    how do i back up deb files?, gonna have to send my phone to vodafone cos its got too many dead pixels and even tho its a hardware issue they'll flash it :@
    also has anyone had a go at installing android cos i might give it a go before i send the phone away, it looks easy enough but i'd rather hear from someone with experience :-D

    matthew_maude wrote:
    how do i back up deb files?, gonna have to send my phone to vodafone cos its got too many dead pixels and even tho its a hardware issue they'll flash it :@
    also has anyone had a go at installing android cos i might give it a go before i send the phone away, it looks easy enough but i'd rather hear from someone with experience :-D
    dead pixels....ouch.  i hope it doesnt take vodaphone a long time to fix your unit.  maybe they can just swap it out for you.
    but in any case, you are right, they will most likely flash the device.
    if it were me, i would:
    1.  create a fresh backup on the device.
    2.  connect my unit to a pc in mass storage mode
    3.  open the n900 folder from the my computer
    4.  copy the Backups folder, and any other data that you want to keep (ie-mobile maps 9/10 folders) to your desktop or where you will remember them.
    then, since you are going to turn it in, i personally, would try all the diffrent software that wouldnt i wouldnt before...and when i was done, i would flash back to orgininal before giving it to vodaphone so that they couldnt say it was some software that i loaded and to shove off! 
    that back up should be fine for you to transfer to your new device, or fixed one and then restore.  which it will then load all your email, conversations, repo catalogs, and application lists and auto install everything, and settings.

  • Will not open PDF files and has been updated

    PDF files do not open after updates in ipad, android mobile or in windows on asus laptop. A great program now unusable.. How to fix this..?  Is this "free" program no longer available.?

    Ok, you haven't told us where the file is from. I'm guessing it's some kind of form (there are other possibilities).
    Some forms are of a special type which can only be opened by very limited software: Adobe Reader on Mac or Windows in fact. They have this built-in message when the current software doesn't know what to do, but unfortunately it's a very confusing message.
    So, that accounts for the problem on tablets. Why the problem on Windows? My guess is that you are trying to open in something other than Adobe Reader, including perhaps Chrome, or FireFox, or Microsoft Reader in Windows 8. Save the file to your desktop and open it in Adobe Reader (current version) and you should at last be able to see the elusive file. I hope it was worth the trouble!

  • Need to design a website that loads files and creates inventory

    I work for an engineering firm that would like to make a website that on one page you can upload PDF files to directories that would be named according to the project number that the user inputs.  After that I would like another page that would be able to list all of these project and have a link that would allow for the PDF file to be viewed.  Unfortunately I am very green to fancy website designs so any help of how to get started would be greatly appreciated.
    Our Web server runs Apache 2 / MySQL and PHP
    Thanks in advance.
    KHeinz

    bregent wrote:
    Without a solid foundation in the underlying technologies, it's pointless to start building a specific solution. It's like starting to build a house without knowing how to use a saw and hammer.
    I agree entirely.
    However, as it happens, I have just added a PHP recipe to the Dreamweaver Cookbook that describes how to upload images to a website. The principle behind uploading PDF files is identical. All that you need to change is the test for the MIME type. The recipe can be found here: http://cookbooks.adobe.com/post_Need_code_to_upload_image-16389.html.

  • NAS! Is it possible to store files and catalog on a lokal NAS.

    I would like to be able work on both my desktop and my laptop.

    If you set up icloud on all devices/computers then pages, numbers, keynote and note pad will sync to all. You edit on ipad and changes will show up on same document on computer.

  • Keywords, Include on Export, Save Metadata to File, and SmugMug???

    My workflow and issue (LR 5.7 and SmugMug plugin 2.1.10):
    1) I import RAW files as DNGs
    2) I do various Lightroom stuff, plus add Keywords. Some of the keywords do not have "Include on Export" checked. Some of my keywords are part of hierarchies that have "Export Containing Keywords" checked. And some of keywords have synonyms.
    3) Once I am all done with a file, I select "Save Metadata to File"
    4) Then I publish to SmugMug using the SmugMug publish service.
    5) The SmugMug website shows keywords which I did not intend to be included on export, it does not show the complete hierarchy for those keywords that should, and none of my synonyms show. I noticed this is the same way the keywords were saved to the DNG when I view the file in Bridge.
    6) When I export the file to a file on my desktop and check the metadata with Bridge, the Keywords all export correctly.
    All of this behavior makes sense, I guess, but I cannot figure out what to do about it. Should I not bother to "Save Metadata to File", this seems to be what is messing up the SmugMug publish service? Is the SmugMug publish service behaving correctly? I would have expected it to behave like an export which would write synonyms, exclude keywords that should be excluded, etc, which seems to work ok in point 6 above. Are the publish services more effort than they are worth? So I get SmugMug to work, what happens when I try Flickr? I hate to stop "Save(ing) Metadata to File(s)", since that seems like a nice hedge against db corruption and the next time I decide to try a whole different image database.
    Any advice on this issue would be greatly appreciated.

    Perhaps someone with direct experience with publishing to Smugmug will chime in.  Short of that, some thoughts on your issues:
    Should I not bother to "Save Metadata to File", this seems to be what is messing up the SmugMug publish service?
    I very much doubt that it is messing up the publishing.  What gets saved to the file from the catalog is independent of what gets exported.  Saving metadata to the file is generally a good practice (in case you screw up your catalog backups).  Many, perhaps most, users set the preference Catalog Settings > Automatically Write Changes Into XMP.
    I would have expected it to behave like an export which would write synonyms, exclude keywords that should be excluded, etc, which seems to work ok in point 6 above.
    Yes, that's a reasonable expectation.
    You may have done this already, but double-check: Right-click the Smugmug publishing service in the left-hand column of the Library, select Edit Settings, and in the Metadata section verify that you have Include: All Metadata set.
    Did you download the Smugmug plugin from Smugmug? You might try this Smugmug plugin instead -- the author designed the publishing architecture of LR and has an excellent reputation. 
    Are the publish services more effort than they are worth? So I get SmugMug to work, what happens when I try Flickr?
    I think many users find the publishing services are generally worthwhile.  I publish regularly to Flickr (using the built-in Flickr plugin, which isn't completely reliable) and the Zenfolio plugin from Friedl. 

Maybe you are looking for

  • Outlook Anywhere, Office 2013 + Exchange 2013 freezes

    Hi. I'm pulling my hair out with this problem as it seems to make no sense. I have a client using outlook 2013 through outlook anywhere to their new server running Exchange 2013. when outlook is opened it seems to work for about 10 mins or so then af

  • /SAPAPO/RESLCT

    Hi,        When I go to product view for a location product, when I click on periods tab, I get the message : === "Time stream from resource XXXXXX not valid for total display period" Time stream from resource WHTST5_0158_001 not valid for total disp

  • HttpSession Bug in WebLogic 6.0?

              I've been having trouble getting sessions restored by jsps in my web           applications under WebLogic 6.0. In order to shed some light on the issue,           I tried deploying the jsp examples in the examples server. When I run       

  • Multiple Bluetooth speakers - selecting and naming issues

    I've recently added a pair of Bluetooth speakers to what had been an all AirPlay setup (5 AX units, 4 Ethernet, 1 wireless). Now I've added a pair of Bluetooth speakers and I'm having some issues in using them iPhone 5 running 7.1 The two Bluetooth s

  • The Wizard Was Interupted

    Help!. I received a BB 8330 today for business. I have had no success in downloading the desk top software. The following is the message displayed in the dialog box each time I try to download the software using the included CDROM. "The wizard was in