Hot Topic (More than 10 Replies) BLOB field types (Read 5036 times)
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
BLOB field types
Jul 15th, 2011 at 12:57am
Print Post Print Post  
Will Sesame 3 have a "blob" data type that allows storing random data with no change (such as an MP3 audio file, Excel spreadsheet, executable file, etc.)?

Will Sesame 3 have a data type than can store and display formatted text? (Most likely an RTF format, since that is pretty much universally understood by programs that handle formatted text, and with the ability to retain basic formatting when copying and pasting between programs, such as copying text from an email and pasting into Word and vice-versa.)
« Last Edit: Jul 17th, 2011 at 3:24pm by The Cow »  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: BLOB field types
Reply #1 - Jul 15th, 2011 at 1:35pm
Print Post Print Post  
Rick_R wrote on Jul 15th, 2011 at 12:57am:
Will Sesame 3 have a "blob" data type that allows storing random data with no change (such as an MP3 audio file, Excel spreadsheet, executable file, etc.)?


Internally, yes. In fact Sesame 2 has a field type for that purpose, as does 3. How do you want to enter this data into the database? How do you wish this type (unspecified binary) of data to be displayed or presented? Currently, it is recommended that you store the file path and filename of the file that contains the "blob" data. That allows the user to present that data using the default program they have selected for its presentation. It also prevents filling valuable database space with a copy of a file that is likely to also remain in the file-system. It is trivial to write a mass update that can collect the contained file paths so that they can be zipped/tarred for transportation to other systems.

Not to say that I won't implement some sort of interface to the BLOB type. We've had it sitting in the engine dormant since before Sesame 1.0. But I'd hate to draw large binary files into the engine simply for the sake of having them there rather than in a directory nearby.

Quote:
Will Sesame 3 have a data type than can store and display formatted text? (Most likely an RTF format, since that is pretty much universally understood by programs that handle formatted text, and with the ability to retain basic formatting when copying and pasting between programs, such as copying text from an email and pasting into Word and vice-versa.)


We can store RTF now. Displaying any formatted document is application specific. RTF, while very useful in that it is an ASCII format (like postscript) and thereby - in some sense "open", is being heavily deprecated by MS. Support by third parties is rapidly waning.

XML and its cousin HTML, also ASCII formatted, are much more prominent. But again and more-so, each document is formatted specifically for a small set of applications and is not generalized. For example, I can have a .xml file that is really a MSWord document and I can have a .xml file that is really the 3D data from Softimage/XSI. And while, Sesame can already tell one from the other and route the data to the appropriate application, it can't display either as anything more that a text file. Very few programs, other than originators, can.

I would like very much to add a PDF (the very closed binary version of Postscript) interpreter to Sesame. PDF is very popular and widely used and unlikely to be deprecated by Adobe. But PDF is licensed technology and very expensive. Existing interpreters are easily available, invokable from Sesame, and usually free. Postscript would be a much better fit for internal-to-Sesame implementation. Unfortunately, in spite of it being far superior to PDF, it is no where near as popular in the MS-World.

I guess, in summary, I am hesitant to implement internal to Sesame, widely available features that are easily invokable from within Sesame from data that provides no benefit by being stored literally inside the database file.
« Last Edit: Jul 17th, 2011 at 3:25pm by The Cow »  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #2 - Jul 16th, 2011 at 3:19am
Print Post Print Post  
Quote:
[quote author=Rick_R link=1309958825/0#15 date=1310691463]Will Sesame 3 have a "blob" data type that allows storing random data with no change (such as an MP3 audio file, Excel spreadsheet, executable file, etc.)?

Internally, yes. In fact Sesame 2 has a field type for that purpose, as does 3. How do you want to enter this data into the database? How do you wish this type (unspecified binary) of data to be displayed or presented? Currently, it is recommended that you store the file path and filename of the file that contains the "blob" data. That allows the user to present that data using the default program they have selected for its presentation. It also prevents filling valuable database space with a copy of a file that is likely to also remain in the file-system. It is trivial to write a mass update that can collect the contained file paths so that they can be zipped/tarred for transportation to other systems.

Not to say that I won't implement some sort of interface to the BLOB type. We've had it sitting in the engine dormant since before Sesame 1.0. But I'd hate to draw large binary files into the engine simply for the sake of having them there rather than in a directory nearby.


I'm thinking, for instance of what FoxPro had--and we did have this discussion before, but not specifically in the Sesame 3 context.

Regarding display, because any type of data could be stored there normally there is no provision to display the data.  If you "look" at the field it only displays some type of "Empty/Not Empty" status indicator.

Regarding entering and retrieving the data, the only thing the program can do is store something to the field, (usually either the contents of the clipboard, a variable, a field, or a binary file), set a variable, a field or the clipboard to the contents of the field, use the field like other fields would be used, e.g., MyData = @Left(BlobField, 1000), or write the contents of the file to a binary file.  Considering that the field content could be 10-100MB or more, you want the ability to read and write files directly without having to use a variable in memory.

I think I may have seen some programs that allow a text-box-like entry "window".  But frankly, I don't see that all the extra work to include that functionality would be useful.  The user could create an unbound text box and then set the blob contents to it.


Regarding, "valuable database space," with 2TB drives commonly available for well under $100, even a 100GB database really wouldn't be that big a deal.  I could easily see storing things like audio files or hi-def photos--even in multiple formats and at multiple resolutions.  For instance, awhile back I was looking into creating a "personal information" database with FoxPro that would have scans of diplomas, tax returns, photos of places I lived, and all sorts of information.  Even though FoxPro is limited to 2GB per DBF file, that still would store a heck of a lot of data as long as I don't include any videos.  Quicken, for example, has an "attachment" feature that lets you attach images of checks, invoices, etc., to an individual entry.


One problem with the "mass update", tar/zip, etc., approach is that it assumes someone fairly knowledgeable will be readily available. From what I have seen, it looks like Sesame's clientele are mainly Windows power users working at companies that can't/won't spend the money to have an outside firm write a custom application from scratch. Or an outside consultant writes the application and an in-house power user handles most of the sysadmin work and can do things like mass updates.  In such cases, as long as the power user who works with Sesame is available, the mass update/archive approach may be viable. But one problem is it does clutter up the system with perhaps hundreds or even thousands of extra files. And then there is also the security issue, making sure users don't access such files. Another problem is the various indexing programs. You either have to make a huge list of "exclude" folders or search results show up hundreds of irrelevant files.  In theory a sysadmin can handle that.  But in a company where the sysadmin is really just a power user or one person is expected to handle everything, those things usually fall by the wayside.  Also, most programmers and sysadmins hate having a huge number of mixed file types.  If they are going to have "associated files", normal practice would be to put all wordprocessing documents in one folder, audios in another, PDF's in another, etc.  And then those probably would wind up being categorized more, e.g., by client, year, decade, etc., with audio/PDF/video folders for each client.  That basically would be unnecessary if the data is in the Sesame table.

Another problem with the mass update/archive approach is old records.  Records from 2+ years ago are removed from the database and archived.  Subsequently, for whatever reason, someone decides to move all the current "associated" "blob" files and does a mass update.  I guarantee you no one is going to remember to reload all the old records, unzip the archived "associated" files, move the "archived associated" to the new folders, mass update everything, and then rearchive and re-remove the old records. And, of course, sooner or later someone is going to need the archived records because an old client is being reactivated, etc.  It's a lot easier to do like Quicken and many other programs--when you exit it asks "Backup database?"  You press OK and 30-60 seconds later it says "Done". That's a lot easier if everything is in a handful of table files.

Realistically, most binary files won't be large. Yes, someone might store a 120-page scanned PDF or videos or executables. But Sesame isn't an "industrial-strength database". Chances are the majority of files would be less than 10MB--probably similar to what typically can be attached to an email.
« Last Edit: Jul 17th, 2011 at 3:25pm by The Cow »  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #3 - Jul 16th, 2011 at 3:37am
Print Post Print Post  
Quote:
I would like very much to add a PDF (the very closed binary version of Postscript) interpreter to Sesame. PDF is very popular and widely used and unlikely to be deprecated by Adobe. But PDF is licensed technology and very expensive. Existing interpreters are easily available, invokable from Sesame, and usually free.

I'm not sure if we're understanding each other here. For years I have used PowerDesk Pro, originally from Ontrack, now from Avanquest,  as my file manager instead of Windows Explorer. One thing they have is a file viewer that displays an extensive number of file types with formatting.  (I'm an attorney, so just its ability to display WordPerfect files makes it worthwhile.) It comes with a built-in PDF viewer that is garbage. But it also has an option "Use Adobe Reader plug-in to view PDF's". When I go to view a PDF, the Adobe Reader comes up in the File View window (the same as it does in FireFox if it is set to view PDF's in the browser with Adobe Reader as the viewer). I assume they just write code that ties to an API. Is that the part that is expensive?  Considering that it's in a free browser I doubt they're paying much if anything for a license.
« Last Edit: Jul 17th, 2011 at 3:25pm by The Cow »  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: BLOB field types
Reply #4 - Jul 16th, 2011 at 3:59am
Print Post Print Post  
Rick_R wrote on Jul 16th, 2011 at 3:37am:
Quote:
I would like very much to add a PDF (the very closed binary version of Postscript) interpreter to Sesame. PDF is very popular and widely used and unlikely to be deprecated by Adobe. But PDF is licensed technology and very expensive. Existing interpreters are easily available, invokable from Sesame, and usually free.

I'm not sure if we're understanding each other here. For years I have used PowerDesk Pro, originally from Ontrack, now from Avanquest,  as my file manager instead of Windows Explorer. One thing they have is a file viewer that displays an extensive number of file types with formatting.  (I'm an attorney, so just its ability to display WordPerfect files makes it worthwhile.) It comes with a built-in PDF viewer that is garbage. But it also has an option "Use Adobe Reader plug-in to view PDF's". When I go to view a PDF, the Adobe Reader comes up in the File View window (the same as it does in FireFox if it is set to view PDF's in the browser with Adobe Reader as the viewer). I assume they just write code that ties to an API. Is that the part that is expensive?  Considering that it's in a free browser I doubt they're paying much if anything for a license.


No, that is not expensive. But nor is it "built in". Sesame can also invoke a PDF interpreter/renderer that is external to Sesame. Either invoke it directly and use the file name as an argument, or use the OS's ability to establish a file association between that file type and the application you (or your user) chooses to view it. Take a look at ASynchShell and the other process management commands.
« Last Edit: Jul 17th, 2011 at 3:25pm by The Cow »  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #5 - Jul 16th, 2011 at 5:34am
Print Post Print Post  
I understand that the Adobe Reader plug-in approach is not "built in", but it sure looks and acts "built-in" to the user.  The PDF document is displayed in a window that is normally part of the application. For instance, when I'm cursoring through a list of file names, if they're not PDF's PowerDesk's file viewer will display the data correctly, switching automatically between a Word document, DBF, spreadsheet, plain text, WordPerfect. When I cursor to a PDF the Adobe plug-in opens in the same window, the window can be resized and moved if it is set as "detached". As soon as I cursor to a non-PDF it switches back.

I'm thinking of a "PDF Reader" layout element.  It could either display content of a BLOB field (if that happened to be in PDF format) or a hard-coded file name (such as a set of instructions) or a PDF whose name is specified in a layout element or variable, or chosen by the file picker.

Incidentally, it probably wouldn't be hard to code the form with text box and PDF layout elements directly on top of each other, and if the item is being displayed is a PDF, disable the text box and hide it and vice versa, giving the appearance one text area is switching automatically.


Update: I think I may have somewhat misunderstood his comment. I think by "standard interface" he meant that the File Open / Save / Save As, etc., dialogs within the Adobe Reader plug-in won't have the same style as other Sesame dialogs, which, of course, is correct.
« Last Edit: Jul 18th, 2011 at 12:31am by Rick_R »  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: BLOB field types
Reply #6 - Jul 16th, 2011 at 4:04pm
Print Post Print Post  
Plug in technology like you are referring to generally relies on one (or more) of three approaches: DDE/OLE/COM, .NET, or a prefabricated DLL enablement.

In the last case, the people that built the application have specifically built it to act as a plugin, using rules they designed - no standards, no uniformity, no predictability. In this case, we would need to write custom code to manage each "plug-in" that we wished to support. Sesame 3 has the ability to call code in a DLL using SBasic, so this could be accomplished by a SBasic programmer, but it is non-trivial.

If provided, DDE/OLE/COM, provides predictability and uniformity. Unfortunately, these are rag-tag pseudo-standards promoted by MS without reasonable support for real life reliability and are being phased-out rapidly both in the field and by MS. I'm afraid that creating an object framework based on the "cut and paste" library developed during the DOS to Windows transition and then misusing the already badly flawed Window's messaging system, and adding poorly understood object orientation as a superficial layer on top of the chaos stew, resulted in less than reliable code.

.NET, as a clone of the Java/XML approach to object management, has some decent chops. Unfortunately, like most of MS technology, it a framework rather than a addable resource and would require a total rewrite of the client. And, of course, like the other two approaches, is not cross-platform.

Over in Unix land, there is support for MONO (like .net), Corba (like COM/DCOM), and in the real old days, there is a way to simply "steal" an X11 Window from one process and embed it in another. This last option may be usable in both Windows and Unix, but it is a half-measure and not terribly elegant.

Invoking the application recommended by the desktop to interpret/display/edit the format provided, and allowing that application to open and display a window for that purpose, while mildly old fashioned, is flexible, works with any set of applications without need for a predictable interface, doesn't clutter the database with unsearchable formats, follows a standard that exists on all modern desktops, is compliant with each user's preferences, and doesn't rely on ever-changing pseudo-standards nor use of special languages, libraries or frameworks.

On the other hand, there are cross platform PDF interpreter libraries available that can display PDF formatted documents. I suspect that the Adobe licensing may only apply to editing/creation. I'll look into whether terms of the licenses are acceptable for inclusion in a commercial product. I would always prefer to base something like this on an open standard, like XML. There are XML formats for text formatting, much like xHTML/CSS, but the Windows world seems to much prefer proprietary approaches.
« Last Edit: Jul 17th, 2011 at 3:26pm by The Cow »  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #7 - Jul 17th, 2011 at 12:57am
Print Post Print Post  
PDF is an open standard.  www.adobe.com/pdf/release_pdf_faq.html  "Adobe first published the complete PDF specification for use without restriction in 1993."  And especially see http://en.wikipedia.org/wiki/Portable_Document_Format

Adobe Reader is available in both Windows and Linux versions and works as a plug-in in both.  (I just installed Reader 9.4.2 in Ubuntu and tried it with FireFox.)  The user interface looks the same between the Windows and Linux versions.  (Although the Windows version is at 10, which has a somewhat different interface.)

I can see not wanting to support "all sorts of random plug-ins" but I think Adobe Reader really should be an exception.  Considering that the IRS distributes all its instructions and forms in PDF format and PACER (Public Access to Court Electronic Records), the federal court system's official court record system, requires all filings (except by prisoners without lawyers) to be done electronically in PDF format -- literally billions of PACER pages per year, and all the major user-publishers link to Adobe's site to download the reader -- Adobe Reader isn't going away in the foreseeable future. Most of the larger state court systems are now switching over to requiring lawyers to file documents electronically and in PDF format--and overall the total number of federal court cases is "a drop in the bucket" compared to the total number of state court cases. And most state and federal agencies now distribute their rules, regulations and manuals in PDF format.
« Last Edit: Jul 17th, 2011 at 3:26pm by The Cow »  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #8 - Jul 17th, 2011 at 1:17am
Print Post Print Post  
Regarding "cluttering the database with unsearchable formats", if the data is stored outside of Sesame, it becomes completely inaccessible to Sesame. Deciding whether to put the data into the database or keep it separate would be the developer's choice. Not every piece of data needs to be searchable--audio, video, images, etc., normally aren't.  The developer could include related Keyword, Tags, Description, Author, etc., fields if they feel such information is important.

However, I would suggest that a "Blob" data type have two separate components--a place where the actual data is stored, and a searchable metadata section editable by the programmer or user. That would be a lot more useful than only being able to store the actual data.  Plus, since so many data formats now include metadata, it is very likely someone wanting to store a video, image, etc., would want to extract the file's metadata and have that available in the database.  Perhaps the metadata could be stored in a stringarray whose name is somehow associated with the blob field. MyVar = BlobData("BlobLayoutElement", "Metadata").  That way the developer could have different metadata elements for different blobs fields.

Also BlobContents = BlobData(Location).  If Location is the name of a LayoutElement, the data will be pulled from the record.  If Location is a file location, it will be pulled from there.  The developer could distinguish by preceding a file location with "file://" or something similar.
« Last Edit: Jul 17th, 2011 at 3:26pm by The Cow »  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: BLOB field types
Reply #9 - Jul 17th, 2011 at 3:20am
Print Post Print Post  
No, not every field needs to be searchable. But, storing large binary data in a database, particularly a RAM based database, is simply wasteful. Sesame can access external files. It can store metadata and searchable fields referring to those external files. Sesame2 can invoke an appropriate program to view and edit those external files, often without having to know anything more than the file extension. Sesame3 can view several formats of video and audio files without any external program.

You have still not convinced me that there is a good reason to store this data inside of the database file itself. The only reason I can think of is to allow someone to pick and move the entirety of the data in one go without having to zip or tar the files. You say it should be the programmer's choice, and generally I agree with that sentiment. But flexibility for mere flexibility's sake, especially at such a high cost, may be leading too many down a unpleasant path, with little gain. And while having such a field type would be more flexible, what else besides an additional choice does it accomplish that cannot be accomplished now using an external file?  

On a 32 bit system, the maximum addressable RAM is 4 gig, much less if you are running Windows. Even storing short videos internally would deplete the available RAM very quickly and, if still addressable at all, cause swapping. On a file system, even in 32 bits, terrabytes are available, addressable, and easily reached by Sesame. Given that even Windows allows for cached reads, filesystem access, even of large files is plenty fast enough to play a video. A 64 bit system, with Sesame3 for 64 bits could hold considerably more. But most desktops, even with 64 bit OS rarely exceed 16 gigs of actual RAM. That is only about enough to hold 3 DVDs and nothing else. Hopefully RAM prices will continue to fall.

Should I implement BLOBs, of any kind, you still have not answered my original question: how do you want them specified and edited? Would the element be limited to specifying a filename and then Sesame would copy that file into the database file? Should the same data (file) apply to multiple records, do you want Sesame to make copy of the file internally for each record that refers to it? Without an external file reference, Sesame would have no way of knowing that it is simply duplicating the same data over again for each record that refers to that data. If it maintains the file path, then it would be necessary to also retain the external file, and storing it internally simply becomes wasteful and redundant.

If this is an immediate need, you can implement them easily on your own. Simply read the file and convert each byte to either base64 or ascii hex and store the result in a hidden element/field. Then when someone needs the data in that field, either convert it back to a file; or better, pipe the converted data to the appropriate viewer using RedirectProcess. If the viewer prefers a networked stream, as many audio/video programs do, you can open any address and port with Sesame's TCP/IP commands.
« Last Edit: Jul 17th, 2011 at 3:26pm by The Cow »  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #10 - Jul 17th, 2011 at 7:17am
Print Post Print Post  
By the way, I think GetBlobData() and SetBlobData() would be clearer names.


To a lot of programmers (me included), "we can call up other programs and store the data as a bunch of external files" sounds like the cobbled-together "I have a cousin who's a computer genius" approach of many freelancers the early 1990's.  At work we have QA, with a conversion program run from a DOS prompt that simply displays a text file as a menu and then returns to a DOS prompt, then the user presses 1, 2, 3 or 4 and that runs a batch file.  That runs a QBasic file.  Then the person copies that file to another folder, then manually loads it into the QA program, etc. There was a completely unrelated program with DOS Procomm to receive one download a day from one client.    For my own use, when I found out that Sesame doesn't have a "blob" data type, I immediately eliminated it from possible use for the "personal information" database I was looking to set up, since I wanted to move the data from thousands of files to a single location.  (I do genealogy as a hobby, so I have a lot more information than just "important papers".)

I just checked the specs for Visual FoxPro and they say the blob data type is limited to "available RAM or 2GB file size".  Realistically, I can't see that anyone would really need to ever store something more than about 10MB.  Most likely that would be something like a very hi-res photo.  It's pretty unlikely anyone would be storing a lot of large blob fields in a single record.

You could poll the various users here and on Facebook about a size cap and if people start complaining that they are regularly exceeding the cap, change it.  Or maybe have the cap set in the ini file. It might be a "hard" cap or just trigger a warning.  Or allow a setting in the ini file to decide whether it is a hard cap or just triggers a warning.  The ini file could also include a default file path for external files being accessed by GetBlobData() and SetBlobData().


Should I implement BLOBs, of any kind, you still have not answered my original question:

How do you want them specified and edited?


I don't recall how FoxPro does it for blob fields but, for example, if you include a memo field in a spreadsheet-type browse display it just displays the word "memo".  If the field is empty it is "memo" in lowercase and if it has content it displays as "MEMO". You have to click on the field to open the edit window (similar to F6 in Sesame). I would say just an "Empty"/"Content" indicator.  If the programmer wants to display the data with a particular program, it would be up to him/her to handle it.  (And since many data files contain a type indicator near the beginning, the programmer could read a small set of the characters and determine the data type.  For instance, all WordPerfect documents contain WPC about 3-4 characters from the start of the file.)

I have not seen any "blob" type that permits editing.  The only exception is that you can either replace the contents or append to the existing contents. I would say that editing should be handled by the programmer--write the blob to a scratch file, call up the appropriate program to edit it, save the modified scratch file, and then back in Sesame replace the existing blob and delete the scratch file.

Loading the data would have to be more programmatic than Sesame's usual form-input paradigm. For instance, the programmer calls up the File Picker dialog and sets the blob field to the contents of the chosen file.  Or the form contains an unbound text box and when the user exits the box some On Exit code sets the blob field to the text box contents.  Or the user can press a "Save Clipboard" command button and the blob will be set to the contents of the clipboard.

Would the element be limited to specifying a filename and then Sesame would copy that file into the database file?

I would say the data source is set as a "DataSource" attribute of the LE.  Most likely it would be Variable (name); some other LE's value; FilePicker; FileName; Clipboard.  If the programmer wants to provide choices (e.g., FilePicker or Clipboard), I assume they could set up a menu, radio buttons, etc., and then change the DataSource LE element on the fly.


Should the same data (file) apply to multiple records, do you want Sesame to make copy of the file internally for each record that refers to it? Without an external file reference, Sesame would have no way of knowing that it is simply duplicating the same data over again for each record that refers to that data.

Actually, yes, that would be necessary. You can't assume that because the data starts the same it will remain the same. For instance, if I have to send the same type of document to several people, I will routinely make an original and then make duplicate copies of the file under various names. I might not get around to changing the contents of the other copies for days.  I could easily see, for instance, someone puts the same image in 3 records, and then for records 2 and 3 copies the blob to the clipboard, pastes it into a graphics editor, changes it from color to grayscale or changes the size or resolution, copies the image back to the clipboard and then copies the clipboard back to the blob.

Whether to duplicate or not would also be to a certain extent up to the user.  For instance, most of our work involves hospital patient accounts, sometimes for the same patient, sometimes not (e.g., multiple patients in the same car accident).  Sometimes in the "history" file the person will simply put "See Account 12345".  Other times they'll retype almost the entire text.  "See Account 1245" does get to be a pain when the main account settles and is removed from the system.

If the programmer is concerned about excessive duplication, it would be fairly easy to write a report that calculates a checksum on the blob contents and then counts how many records have duplicate content.  That could also help the design in that if there is a lot of duplication, maybe there needs to be a command button that will do various things automatically that users have been doing manually each time. Or, it might indicate that something is a regular activity or recurring problem and every time it has come up people have been treating it as if it is a one-time event.


If it maintains the file path, then it would be necessary to also retain the external file, and storing it internally simply becomes wasteful and redundant.

That should be determined by examination or deciding how the users will use the data.  If the users are going to use the same 5 form letters about 30 times a week, the programmer should know that and not put the data in a blob field. But if the contents are likely to routinely vary, some duplication isn't significant.

In the example I gave before where GetBlobData(Location) is a file location, I would assume that GetBlobData() is really two separate functions internally.  If Location is a filename, GetBlobData() would simply read content from that file. If Location is a Layout Element, then the data would be pulled from that blob field in the database.  From the programmer's perspective, s/he would not have to use one set of functions to read/write data to a blob field in the database and a different set to read/write to an external file.

Instead of indicating that Location is an external file by adding something like "file://" to the path name, an alternative might be to include an "Internal/External" attribute. However, adding something to the name could be more flexible by allowing full-blown URL's.

By the way, if SetBlobData(Location) can write an external file, it probably would be a good idea to include an attribute for read-only/change/write/delete permissions.
« Last Edit: Jul 17th, 2011 at 3:26pm by The Cow »  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: BLOB field types
Reply #11 - Jul 18th, 2011 at 12:25am
Print Post Print Post  
This is a description from FoxPro's help:


To store binary data of any kind, such as ASCII text, an executable (.exe) file, or a stream of bytes, and with indeterminate length, use the Blob data type. Blob data types are particularly useful for storing Image data from SQL Server.

You can assign values to a Blob field using binary literals. Binary literals begin with a prefix, 0h, followed by a string of hexadecimal numbers and are not enclosed with quotation marks (""), unlike character strings. The following list includes examples of binary literals:
  • 0h202020
  • 0h6ABCDEF
  • 0h (empty binary literal)

Binary literals are limited to 255 encoded bytes.


(Comment -- for short strings I'd say that the programmer should just write a routine that converts the binary string to ASCII hex values for storage in a standard text field and upon retrieval converts the hex to the binary values.)

To store binary values of fixed length, use the Varbinary data type instead. For more information, see Varbinary Data Type.

Support for Blob Data Type

You can view the contents of a field with Blob type using an EditBox control, a TextBox control in a Grid control, or by issuing the MODIFY MEMO command with the name of the Blob field; however, the contents are read-only. The edit box displays Blob type data as hexadecimal values without the 0h prefix. In grids, Blob type fields display the string "blob" if they are empty, and the string "Blob" if they contain data. You can double-click the Blob field in the grid, and an editing window displays the data as read-only.

Index keys based on Blob fields are not supported. No code page translation is performed on data with Blob type.



Note: Issuing a MODIFY MEMO command in FoxPro pulls up a built-in ASCII text editor, similar to pressing F6 in Sesame. MODIFY MEMO is based on XBase. When Microsoft switched from FoxPro 2.6 for Windows to Visual FoxPro 3 it added extensive objected-oriented functionality. A "grid" object is basically a spreadsheet object similar to the XBase BROWSE command.

Frankly, given the "unknown" nature of the data that would be stored in a Blob field, I just can't see the need for any ability to display the content. For instance, if the field contained XML, HTML or plain text, the programmer should know that.  If they want to display it as text, they can set an unbound text field equal to the blob contents and even save any changes back to the blob field.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: BLOB field types
Reply #12 - Jul 18th, 2011 at 1:04pm
Print Post Print Post  
Rick, I am still unconvinced that this type has enough value to be worth the cost. Can you outline the advantages that this provides other than "not appearing old fashioned" over using an external file system vector system. I see two:

1. It provides a way to keep all of your eggs in one basket, which while useful for moving files does also cause additional risk: one bad block and all your critical "files" are toast.

2. It prevents external removing / renaming from affecting a previously edited record.

In address to your belief that it is "cobbled", I was able to find several hundred recent "white papers" from MS, IBM, Oracle, and other prominent software/database companies debating the merits of each approach under different circumstances. Clearly, both approaches are current and in different cases useful. That any system could be "cobbled" is more a reflection of the limitations of its application level design, than a reflection of its era. Both approaches have been with us since the 1960s and both have been used, tested, metered, and debated since then.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged