Using DataLinks

 

The DataLink data type is one of the basic building blocks for extending the types of data that can be stored in database files. The idea of a DataLink is that the actual data stored in the column is only a pointer to the object.

This object can be anything, an image file, a voice recording, a text file, and so on. The method used for resolving to the object is to store a Uniform Resource Locator (URL). This means that a row in a table can be used to contain information about the object in traditional data types, and the object itself can be referenced using the DataLink data type. The user can use SQL scalar functions to get back the path to the object and the server on which the object is stored (see Built-in functions in the SQL Reference). With the DataLink data type, there is a fairly loose relationship between the row and the object. For instance, deleting a row will sever the relationship to the object referenced by the DataLink, but the object itself might not be deleted.

A table created with a DataLink column can be used to hold information about an object, without actually containing the object itself. This concept gives the user much more flexibility in the types of data that can be managed using a table. If, for instance, the user has thousands of video clips stored in the integrated file system of their server, they may want to use an SQL table to contain information about these video clips. But since the user already has the objects stored in a directory, they only want the SQL table to contain references to the objects, not the actual bytes of storage. A good solution is to use DataLinks. The SQL table uses traditional SQL data types to contain information about each clip, such as title, length, date, and so on. But the clip itself is referenced using a DataLink column. Each row in the table stores a URL for the object and an optional comment. Then an application that is working with the clips can retrieve the URL using SQL interfaces, and then use a browser or other playback software to work with the URL and display the video clip.

There are several advantages of using this technique:

Using DataLinks also gives control over the objects while they are in "linked" status. A DataLink column can be created such that the referenced object cannot be deleted, moved, or renamed while there is a row in the SQL table that references that object. This object are considered linked. Once the row containing that reference is deleted, the object is unlinked. To understand this concept fully, one should know the levels of control that can be specified when creating a DataLink column.

 

Parent topic:

Processing special data types

 

Related reference


Data types