US 5,680,618 AGrant
Driver Query and Substitution for Format Independent Native Data Access
Issue Date:1997-10-21
•28 Claims
•11 Drawing Sheets
Abstract
A data access system of the present invention includes an interface (client), a data engine having a common application programming interface layer, and data drivers. Through the drivers, the data engine (responding to client requests) accesses foreign data objects, which may include information tables, files, and other data objects of a foreign format. In this manner, the system provides a virtual interface between a client (e.g., database manager) and individual foreign data objects (e.g., database files). Regardless of the format of the individual database files, all files can be shared without the need to make copies.
Metadata
Assignee
- Borland International, Inc.
Inventor
- Gregor Paul Freund
Application Information
Application Number:US 5617405
Filing Date:1995-11-22
Priority Date:1993-05-26
Art Unit:237
Classifications
IPC:
G06F 1730
Field of Search:
395600;155;157;159;161;616;607;681;682;601;685
Patent Drawings (11 sheets)
Description
Copyright Notice
A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
Background of the Invention
The present invention relates generally to the field of information processing and, more particularly, to database management systems.
Computers are a powerful tool for the acquisition and processing of information. Computerized databases can be regarded as a kind of electronic filing cabinet or repository for collecting computerized data files; they are particularly adept at processing vast amounts of information quickly. As such, these systems serve to maintain information in database files or tables and make that information available on demand.
A "database" is an organized collection of related information or data stored for easy, efficient use. A database is perhaps most conveniently viewed as a stored collection of "records" comprising one or more "fields" of information. Generally, the records are stored in a database file on a storage device. When access to the database is desired, the file, or a subset thereof, is loaded (transferred) from the storage into addressable memory (e.g., random-access memory) where it can be sorted or other manipulated to provide desired lists and reporting capabilities.
Although the term "database file" is generally associated with one of the well-known PC Database Management System (DBMS) file formats (e.g., .DBF file for a dBASE.RTM. created file), other data files may function as a database file as that term is used herein. A spreadsheet file, although commonly used for storing financial information, is nonetheless one type of database file. Another database may contain client address information and still other databases may contain product lists and information. Thus, any data object capable of storing an organized collection of related information may be considered as a database file.
Between the actual physical database itself (i.e., the data actually stored on a storage device) and the users of the system, a DBMS is provided as a software cushion or layer. In essence, the DBMS shields the database user from knowing or even caring about underlying hardware-level details. Typically, all requests from users for access to the data are processed by the DBMS. For example, information may be added or removed from data files, information retrieved from or updated in such files, and so forth, all without knowledge of underlying system implementation. In this manner, the DBMS provides users with a conceptual view of the database that is removed from the hardware level.
A database management system is defined as "relational" when it is able to support a relational view of data. This means that data which a user can access and the operators which the user can use to operate upon that data are themselves relational. Data are organized as relations in a mathematical sense, with operators existing to accept relations as input and produce relations as output. Relations are perhaps best interpreted by users as tables, composed of rows (tuples) and columns (attributes).
Relational database management systems include the ability to "link" tables--that is, to establish relationships between tables by linking corresponding fields. In this manner, information from several different tables can be combined in a transparent, useful manner. For instance, a customer invoice (report) may be generated by linking a Customer table comprising Customer No., Name, and Address fields with an Orders table comprising Customer No. and Invoice Price fields; in this instance, the link is effected through the Customer No. fields. The general construction and operation of database management systems, including relational ones, is known in the art. See e.g., Date, C., An Introduction to Database Systems, Volume I and II, Addison Wesley, 1990; the disclosures of which are hereby incorporated by reference.
Of particular interest to the present invention are those information processing systems which are operative in a shared fashion, i.e., by multiple users at a given time. A multi-user database implemented on a client/server platform is one such system. Typically, information sharing or connectivity between the users is provided by a network, which comprises several computers connected together as a group. At least one of the PCs functions as a "server," providing network services to "clients" (other computers) on the network. In a typical configuration, the clients or terminals access a central storage location of the server which contains database information. Each terminal may have its own local memory for storing application programs or other information or data. In this manner, valuable resources, such as programs, information tables, memory, disk space, printers, and the like, may be shared by several users.
Inherent in any multi-user computing system is a basic conflict between data integrity and concurrency, i.e., the need to let many users access the same data simultaneously. To ensure data integrity, such a system could allow only one user to use a data table at any given time, but this would be highly inconvenient to other users. On the other hand, the system could allow anyone on a network to use any table at any time. Such unrestricted access, however, would quickly lead to inconsistencies in the data. The need for insuring data integrity, therefore, must be balanced with the need to provide maximum concurrent access. Thus, an important issue in designing any multi-user application is deciding how to resolve simultaneous requests for the same resources.
The need for concurrency control is perhaps most acute in a multi-user database system, where information is frequently or even constantly being updated by several users. Suppose, for example, that two users are both executing an application that reads a particular value from a database, performs a calculation on the value, and writes a new value back to the database. If this process begins concurrently, both users will read the same database value, e.g., three. Suppose the calculation is to increment the database value by one. After both users have finished, the new value stored in the database will be four. However, the correct value desired is five, since each of the two intended to add one to the value of three. Thus, the concurrent actions of two processes have interfered, leaving incorrect data in the database.
Sharing database information from database tables of a single vendor's system has been relatively straightforward. A "lock manager" is employed for coordinating processes and controlling access to shared resources. With locks, objects (e.g., tables, reports, forms, and other resources) are restricted in such a way that interference problems are minimized or eliminated. This avoids the problem of, say, a user updating an object while another user is viewing it (with its old data). In this manner, multiple users may transparently access the same resources in the same database at the same time, with data integrity fully maintained.
Despite the ease with which database tables of a single-vendor system may be shared, sharing tables created from a variety of vendors is particularly problematic. Since each database vendor utilizes a proprietary file format--one designed for enhancing system performance--tables and data objects of one vendor cannot be directly shared with those of another vendor. Yet in any large corporation, a number of different databases are typically employed for maintaining different types of its information. For instance, the accounting department for such an organization may maintain accounts payable information on a UNIX minicomputer. The shipping department, on the other hand, may employ custom application software, such as a PC DBMS application program. The data of interest may not even reside in a "database" system; a customer table may, for instance, be stored in a spreadsheet data file (e.g., 1-2-3's. .WK1 file).
From the user's perspective, such details--ones directed to the physical implementation--are completely irrelevant; the user is interested only in access to needed information. Thus, regardless of the form in which a corporation's information may be maintained, it is highly desirable that such information be readily available to appropriate decisionmakers of the corporation--that the data be readily accessible independent of format or other proprietary considerations.
One approach to sharing data from disparate systems is the process of "importing" and "exporting" data files. Typically, database and other information management systems (e.g., spreadsheets) include an import/export capability which allows the information stored in the database to be converted to and from other formats. Paradox.RTM. (ver. 4.0), for instance, includes the ability to import and export data files from 1-2-3.RTM., dBASE.RTM., or Visicalc.RTM., or even ASCII text files.
The process of converting data from one format to another entails several problems. For one, the process is time consuming, and often imported data are not unusable--requiring the wholesale re-input of the data. Even if data were converted without error and in a time-efficient manner, another problem lurks. Specifically, the database manager must generate a copy of the original data with which to work. Thus, if real-time or "live" manipulation of the data in a multi-user environment is desired, the changes made to the copy must somehow be posted back to the original. The use of copies in a multi-user environment of data is unacceptable as uncontrolled use of multiple copies quickly leads to an inconsistent database. And since each copy is of a particular proprietary format (and incompatible with other formats), standard integrity mechanism, such as "locking", cannot be readily employed.
The problem will be further illustrated with the prior art system of FIG. 1. A host computer system 10 includes a database manager or DBMS 21 for accessing a plurality of data tables 23, 25, 27. The data tables or files are stored in a proprietary file format of DBMS 21. Although the tables 23, 25, 27 may be accessible on a shared basis (e.g., across a network), they cannot be directly shared with another database manager. For instance, DBMS 31 is another database manager, operating under another host (host 40), which includes its own proprietary-format tables 33, 35, 37. It cannot directly share the data tables 23, 25, 27 of DBMS 21; nor can DBMS 21 directly share the data tables 33, 35, 37.
To manipulate a table of DBMS 31, DBMS 21 must first make a copy of that table. For example, to access information in table 37, the table is imported or converted to a table 37' which is in a format acceptable to DBMS 21. The operations and commands of DBMS 21 for manipulating information are available for the copy 37', not the original table 37.
A disadvantage of using a copy of database records is the problem of maintaining concurrency between the copy and the original table. If a change to a customer's address is posted to the copy table 37', for example, the table 37' is no longer concurrent with the original table 37. Until the user of the copy exports an updated copy back to the table 37, that user is working with a copy of data which may be outdated.
What is needed is system and methods which allow a plurality of information sources, such as database files, to be accessed and shared by a single host regardless of file format or other proprietary considerations. Moreover, such a system should not require the making of an additional copy of the individual files.
Summary of the Invention
The invention provides a method and apparatus for accessing foreign data objects (e.g., files of different formats) to be accessed in a shared fashion. Instead of creating a copy of a file, the invention permits access to the original file. This allows all updating of the individual data objects to be done in real time. For instance, when a user updates a portion of a database, that updated portion is immediately available to all users who have access to that database.
A data access system of the present invention includes an interface (client), a data engine having a common API layer, and data drivers. Through the drivers, the data engine (responding to client requests) accesses foreign data objects, which may include information tables, files, and other data objects of a foreign format. In this manner, the system provides a virtual interface between a client (e.g., database manager) and individual foreign data objects (e.g., database files). Regardless of the format of the individual database files, all files can be shared without the need to make copies. In addition, all sorting and reporting capabilities of each database remain intact.
In operation, a user requests data from a particular data object through a familiar client interface. The request is routed through the data engine which invokes the driver module appropriate to the type of data being accessed. In particular, the driver is loaded dynamically (i.e., at the time of request for the object), with data engine callbacks registered in the driver. The desired information is selected and accessed by the user. In this manner, the user can access and manipulate foreign data (not a copy of the data) in real-time, including in multi-user environments. Any changes the user makes are instantly reflected in the native data object.
Brief Description of the Drawings
FIG. 1 is a block diagram illustrating the relationship between prior art database managers and individual data objects (e.g., database files).
FIG. 2A is a block diagram of a computer system in which the present invention is operative.
FIG. 2B is a block diagram of a database management system (DBMS) which is operative in the system of FIG. 2A.
FIG. 2C is a block diagram illustrating a data object (e.g., data base file with supporting index).
FIG. 2D is a block diagram of a multi-user computing environment, such as a local area network (LAN), in which the present invention may be embodied.
FIG. 3 is a block diagram illustrating a data access system of the present invention.
FIG. 4 is a flowchart illustrating a method of the present invention for data access with dynamically-loaded drivers.
FIG. 5 is a block diagram illustrating processing of a request to create an Xbase index on a spreadsheet file.
FIGS. 6A-D are block diagrams of the data access system of the present invention operative in various shared environments.
Detailed Description of a Preferred Embodiment
The following description will focus on embodiment of the present invention in a multi-user database environment. The present invention is, however, not limited to any particular exemplary embodiment. Instead, the teachings of the present invention may be advantageously applied to a variety of architectures. Application of the present invention is particularly advantageous in those environments requiring access to data of disparate formats, particularly when such access is desired in a shared (e.g., multi-user or multi-tasking) fashion. Therefore, the following preferred embodiment and certain alternatives are offered for purposes of illustration and not limitation.
As used herein, the term "database" refers to any file or collection of files that are used to store an application's data. For example, a spreadsheet file can be considered a database using the present invention. In addition, a database can be a purely virtual object such as data on a remote machine.
General Architecture
The present invention may be embodied on a computer system such as the system 200 of FIG. 2A, which includes a central processor 201, a main memory 202 (e.g., random-access memory or RAM), an input/output controller 203, a keyboard 204, a pointing device 205 (e.g., mouse, track ball, pen device, or the like), a display device 206, and a non-volatile or mass storage 207 (e.g., hard or fixed disk, optical disk, magneto-optical disk, or flash memory). Processor 201 includes or is coupled to a cache memory 209 for storing frequently accessed information; memory 209 may be an on-chip cache or external cache (as shown). System 200 may also be provided with additional input/output devices, such as a printing device 208, as desired. The various components of the system 200 communicate through a system bus 210 or similar architecture, as shown.
Illustrated in FIG. 2B, a computer software system 220 is provided for programming the operation of the computer system 200. Software system 220, which is stored in system memory 202 and on disk memory 207, includes a kernel or operating system 221 and a DBMS 224. OS 221 is the executive or supervisor for the system 200, directing both task management and data management.
DBMS 224, on the other hand, is a software subsystem for storing, retrieving, and manipulating information in database tables (e.g., tables 231, 232, 233). Under the command of DBMS 224, the system 200 receives user commands and data through user interface 222. Interface 222 includes a built-in query surface or editor for accessing and processing database information. Additional application programs, such as DBMS application software 223, may be "loaded" (i.e., transferred from storage 207 into memory 202) for execution by the system 200, particularly for further controlling the operation of DBMS 224.
In a preferred embodiment, the system 200 is an IBM-compatible personal computer system, available from a variety of vendors (including IBM of Armonk, N.Y.), and operating system 221 is MS-DOS operating system software, available from Microsoft of Redmond, Wash. DBMS 224 is preferably a relational database management system (RDBMS). More preferably, DBMS 224 includes Paradox.RTM. Database Management System (available from Borland International of Scotts Valley, Calif.). As interface 222, Paradox provides a worksurface or "canvas" and a command menu; a QBE query worksurface is also provided. Application software 223, in turn, include database command-language applications (e.g., PAL.TM. scripts), which may be executed or otherwise acted upon by the DBMS 224.
At the outset, it is helpful to understand general techniques for storing information in DBMS 224. In a relational database management system, information is organized into tables, such as table 235 of FIG. 2C. As conceptually shown, table 235 typically includes horizontal rows or records (tuples) 238 and vertical columns or fields 240. A database record includes information which is most conveniently represented as a single unit. A record for an employee, for example, may include information about the employee's ID Number, Last Name and First Initial, Position, Date Hired, Social Security Number, and Salary. Thus, a typical record includes several categories of information about an individual person, place, or thing. Each of these categories, in turn, represents a database field. In the foregoing employee table, for example, Position is one field, Date Hired is another, and so on. With this format, tables are easy for users to understand and use. Moreover, the flexibility of tables permits a user to define relationships between various items of data, as needed.
By employing one or more database indexes, the records of a table can be organized in many different ways, depending on a particular user's needs. As shown by index 245 of FIG. 2C, for example, an index may be constructed as a single disk file which is referred to internally by the system for locating and displaying records in a database file. Index 245 stores two types of information: index key values 246 and unique record numbers 248. An index key is a data quantity composed of one or more fields from a record; keys are used to arrange (logically) the database file records by some desired order (index expression). Record numbers, on the other hand, are unique pointers to the actual storage location of each record in the database file. In this manner, an index for a database file is similar to the index of a book, which lists subject keys and page numbers that point to where the actual information is located in the book. Specifically, an index organizes (logically not physically) the records in a database file according to the values in one or more fields of interest. As such, an index may greatly speed up searches (queries) for information.
Network Architecture
While the present invention is operative within a single (standalone) computer (e.g., system 200 of FIG. 2A), the present invention is preferably embodied in a multi-user computer system, such as the client/server system 250 of FIG. 2D. Specifically, system 250 includes a first computer or file server 280 and one or more second computers or clients 260. In an exemplary embodiment, the clients or workstations 260 are connected to server 280 through a computer network 270, which may be a conventional local area network (LAN). Network 270 includes cabling 275 for connecting the server and each workstation to the network. The workstations themselves will be similar to or the same as system 200; additionally, each typically includes an adapter 265 for receiving the network cable 275. Server 280 may also be similar to or the same as system 200. Because the server manages multiple resources for the clients, it should preferably includes a relatively faster processor, larger mass storage, and more system memory than is found on each workstation.
Overall operation of the system 250 is directed by a networking operating system 281, which may be stored in the server's system memory; in a preferred embodiment, 0S 281 includes NetWare.RTM., available from Novell of Provo, Utah In response to requests from the clients 260, the server 280 provides various network resources and services. For instance, multiple users (e.g., workstations A, B, and C) may view a database table stored in file server storage 283, while another user (e.g., workstation E) sends a document to a network printer (not shown). Of particular interest to the present invention is use of system 250 for multi-user database access, which is described next.
Data Engine-based Data Access System
The present invention provides a method and apparatus for accessing data regardless of the format of the database source. The result is a "shared data" system as opposed to a "copied data" system. The shared data system allows multiple users to access original data files and a variety of database file formats.
Shown in FIG. 3, a data access system 300 of the present invention includes a client 310, a data engine 320, and drivers 340. Through the drivers 340, the system accesses foreign data 350, which may include information tables, files, and other data objects of a foreign format. The components of the system 300 will now be described in detail.
A. Client
Client 310 provides the user with a consistent interface--one which is independent of the foreign data sought to be accessed. Without knowing the underlying structure of foreign data 350 or methods for access of that data, the client 310 performs operations of retrieving information, updating information, adding new information, and the like to the foreign data 350.
Preferably, the client 310 provides an interface which is compatible with one already familiar to the user. A user of dBASE.RTM., for instance, would select an Xbase (dBASE-compatible) client. A spreadsheet user, on the other hand, would be more comfortable with a spreadsheet client. In this manner, the client 310 provides a consistent user interface for effecting operations through the data engine 320.
B. Data engine
As shown, the client 310 is operably coupled to the data engine 320. The data engine 320, in turn, functions as a manager of drivers--opening and closing drivers as they are needed for foreign data access. The engine loads one or more drivers from disk, maintaining a count of active drivers. The data engine 320 acts as an interface 321 between the client 310 and the drivers 340. For this purpose, the engine includes a common API 325--an intermediate layer through which the engine may communicate with various drivers.
On the first open operation of foreign data, the data engine locates the most appropriate driver. In this regard, the engine invokes each driver with the data object of interest until an appropriate one is found. When a driver is found, it returns a handle to the desired information. Through the handle, the data engine provides a distribution of calls to the drivers 340 and creates data structures necessary (e.g., calling table and calling vectors) for supporting an instance of a data object (e.g., certain table for a requested cursor).
As shown by the figure, the data engine 320 also includes operating services 326. Specifically, access routines common to data objects may be stored centrally in the data engine 320. In this fashion, a driver need only include functionality for its intended data object which is not supported by the services 326; this greatly simplifies the task of writing individual drivers. Common core services include file I/O, memory management, conversion routines, exception handling, and the like.
C. Drivers
As shown, the data engine 320 is operably coupled to data drivers 340, each of which is specific for accessing a certain type or format of data. Each of the drivers 340 includes data access methods specific for its intended data and is accessible from the data engine through a common Application Programming Interface (API). As shown, the common API layer 325 is (conceptually) interposed between the data engine 320 and drivers 340. Thus from the perspective of the data engine 320, each of the drivers has the same interface (of API 325).
Although a driver includes access methods specific for its intended data, most of the machinery for data access is preferably maintained in the data engine 320, at operating services 326. Specifically, a callback mechanism is provided whereby core services of the data engine may be registered with the drivers. When a driver receives a request for an action, the driver preferably invokes a callback routine in the engine. To open a spreadsheet file, for instance, a spreadsheet (.WK*) driver would satisfy the request, at least in part, by invoking file I/O services of the engine. Only those data-specific services which are not supported by the data engine need be provided by a driver.
In a preferred embodiment, the drivers 340 are implemented as a set of object-oriented classes. In particular, a base class or superclass is provided having default functionality, such as dBASE.RTM., Paradox.RTM., and other desired default compatibility. Each format-specific driver, on the other hand, is implemented as a subclass--adding or overriding methods as is needed to support the intended or target data type. Preferably, drivers should be constructed to provide pure data access, that is, functioning at a low level to support representations of the largest amount of data. Sorting or higher-level functionality, for instance, would be provided at a higher level (e.g., by the client or as an extended function).
Although a driver is typically designed to access a single format of data, a driver may access a species or multiple formats of data. A spreadsheet driver, for example, may access different varieties of spreadsheet formats (e.g., 1-2-3.RTM., Quattro.RTM. Pro, Excel.RTM., and the like). Moreover, multiple drivers may be active at any given instance, thus permitting complex interaction among foreign data objects (e.g., a "join" operation performed between a spreadsheet table and a database table).
Common API
The Common API 325 functions as a lingua franca or common language for communicating with foreign data objects. The API 325 defines a number of core database calls usable with all data types and formats. For example, certain databases supported by the present invention, such as text strings or spreadsheets, do not have database indexes. The API calls of the system allow a user to access such a file and perform general operations such as opening and closing the file, going through the file forward or backward, changing data, updating data, and the like.
The Common API also simplifies the task for third party vendors. A vendor need only create a driver which maps the API calls into its particular proprietary format, and only to the extent that the format is not already supported by the default driver.
A. System data members
Before describing an exemplary API in detail, the data structures supported by the API will first be introduced.
USEDATA
The data engine employs an intermediary data structure, USEDATA, to encapsulate information about a foreign data object. When a foreign data objected is opened, a USEDATA data structure is allocated as follows:
The USEDATA data structure serves as a communication link between the data object of interest and the system.
In an exemplary embodiment, a USEDATA structure is moveable, that is, it may be moved around in memory by the client at unknown times. Therefore, the only pointer to a USEDATA structure which should be employed is the pointer that is provided as a parameter to a data engine function. In particular, no data structures should be created which contain pointers to USEDATA structures.
CURRENT RECORD
For each open relation there is a Current Record. All record and field operations performed by the host on a given relation are performed on the current record. In particular, the DbLoad and DbSave functions implicitly refer to the current record. Each field of the current record is pointed to by the fddata field in the appropriate fielddata structure of the FIELDDATA array for the given relation.
The client makes no assumptions about the physical structure of the current record. Instead, the client accesses the current record on a field-by-field basis only, by using the pointer to the field contained in fddata of the FIELDDATA structure. The operations of loading and storing field values are invisible to the data engine. The current record should contain space for an additional field, one byte in length, which follows the data of the last field. This field will contain a record-deleted byte.
CURRENT RECORD LOCATION
The current record location is contained in the urecnum field of the USEDATA Structure. This is a logical value which is defined to be the file location (i.e., record number) that the Current Record is read from when a DbLoad is performed, or stored into when a DbSave is performed.
Loads and stores are permitted to be "lazy." That is, the current record does not need to be read from the database file each time the current record Location is changed (i.e., via DbGoto), but only when a DbLoad operation is performed.
RECORD NUMBERING
Records are numbered from 1 to 2.sup.32. Record numbers are unsigned long integer data type. There may be gaps in the record numbers, i.e., record numbers do not need to be allocated sequentially.
FIELDDATA/FIELDDATA ARRAY
The ufields member is a pointer to an array of FIELDDATA which defines the fields of a relation. It is created by DbOpen and DbCreate. The array contains one FIELDDATA structure for each field of the relation. All FIELDDATA structures for the same relation are stored contiguously, and terminated with one extra zero byte. For a relation containing (n) number of fields, for instance, the structures would be stored as:
The FIELDDATA structure itself may be constructed as follows:
where fdtype contains the field type and must be one of `C`, `N`, `D`, `L`, `M`, or 0; fddata points to the field's data in the current record; fdlen is the length of the field's data; fddec is the number of decimals in numeric data; fdreserved is reserved for future use; fdstat contains status information about the field, with Bit 0=field dirty bit and Bits 1 to 15 are reserved for the host; fdnlen is the fieldname length; and fdname is the first byte of the field name. The fieldname is stored contiguously from here.
Because fieldname's lengths vary from application to application the FIELDDATA structure is a variable size structure. Its exact size is given in ufnamesize. The total size of the FIELDDATA structure is given by ufstrucsize. This allows an application to store additional information in the FIELDDATA structure.
B. API calls
In an exemplary embodiment, the following database calls may be provided setup and management of a data access session.
Each will now be described in greater detail.
DbInit initializes the engine environment, such as the current working directory. It is called once just after the engine is loaded. A suitable function prototype for the call is:
where the function returns a value of 0 for success and otherwise returns an error code.
DbExit, which is called once just before the engine is unloaded, shuts down the database engine. A suitable function prototype for the call is:
where the function returns a value of 0 for success and otherwise returns an error code.
DbOpen opens an existing database file. It may be prototyped as:
As shown, DbOpen is called with a pointer to a USEDATA structure and with a pointer to the filename of the desired target data (the filename being passed as a null-terminated or asciiz string).
An exemplary use of the call is:
Here, DbOpen initializes the USEDATA and allocates and initializes FIELDDATA and the Current Record. Most of the USEDATA is initialized to 0 before DbOpen is called. ufnamesize contains the length of fieldnames in the FIELDDATA structure. The ufstrucsize member contains the actual size of the FIELDDATA structure. The underlying data file is also opened and all initializations required for subsequent calls to the database engine are performed. The function constructs the FIELDDATA array; allocates space for the current record; sets ualias to the name of the database (without path and extension); sets udbtype to the name of the database type; sets ufields to point to the FIELDDATA array; sets uldate to the date of the last update to the database; sets urecsize to the size of the current record; sets urecnum to the current record; sets ufilfirst to the first record in database; sets ufillast to the last record in database; sets ufilsize to the number of records in a database; sets uhandle to the database file handle (if relevant); sets uengine--a 32 byte work area that is used by the database engine (the area can be initialized with any information that will be required on subsequent database engine function calls); and updates the filename pointer.
DbOpen takes data type conversion into account when creating FIELDDATA and chooses the best matched conversion between the database and the host. If any operation fails (e.g., cannot open file, or cannot allocate required memory), then DbOpen will undo those operations that have been completed (e.g., successful memory allocation). The function returns 0 if successful, otherwise an error number is returned. Some errors with DbOpen include (1) target file not found; (2) file not a FOREIGN database file; and (3) insufficient system memory.
DbCreate creates and opens a data object. It may be prototyped as:
For instance, it may be used as follows.
DbCreate is similar to DbOpen, except that it is called with the name of a database file which it will create. DbCreate creates all data structures analogously to DbOpen. In a typical implementation, a DbCreate call will just create a database file and then use DbOpen to open it. Also, it is called with a pointer to a FIELDDATA array which defines the fields of the new database. The FIELDDATA array that is passed to DbCreate should preferably not be used to initialize USEDATA structure. A new FIELDDATA array should be allocated and the values copied from the passed array to the new array, because the database engine does not know how the passed FIELDDATA array was allocated.
DbCreate is invoked with a pointer to a USEDATA structure, a pointer to a null-terminated text string containing the target file name, and a pointer to a FIELDDATA array which defines the fields of the new database. The function returns 0 if successful, otherwise it returns an error number. Errors include, for example, "file already exists" or "insufficient memory."
DbExist tests whether a database file exists. The prototype for DbExist is:
An exemplary use of the function is:
As shown, the function is called with a pointer to a USEDATA structure and with a pointer to a null-terminated text string containing a file name. The function returns 0 if the file exists, otherwise an error number is returned. If the file exists then the filename pointer is incremented to the end of the string. File does not exist in the error return.
DbClose closes a database file, frees all data structures associated with the file, and performs any additional cleanup required. An exemplary prototype for the call is:
An exemplary use of the function includes:
As shown, DbClose is called with a pointer to a USEDATA structure. The call returns 0 if successful, otherwise an error number (e.g., for "disk full") is returned.
DbGoto, DbSkip, DbTop, DbBottom, DbEof are calls which update the current record number in USEDATA, indicating a new record position in database file. Each may be respectively prototyped as follows:
An example use, such as for DbGoto, includes:
Each call is invoked with a pointer to a USEDATA structure and a flag to return (DB.sub.-- EOF, DB.sub.-- BOF, 0). DbGoto includes an additional "recNum" parameter for specifying a desired record number to navigate to; DbSkip includes a "num" parameter for specifying a skip number, that is, a number of records to skip.
In operation, these calls seek to the desired record number, and return a value (e.g., in a flag) indicating whether the new position is at beginning of file, end of file, neither or both. The database engine does not load data on a DbGoto call and does not necessarily have to perform the seek at this time (i.e., "lazy seeking"--deferring the seek until a DbLoad, DbSave or DbAppend call). DbSkip is the same as DbGoto except that the seek is relative to the current position. The Skip can be positive or negative. DbTop is the equivalent to DbGoto(&u, u.ufilfirst, &flag ).
DbBottom is equivalent to DbGoto(&u, u.ufillast, &flag). DbEof is equivalent to DbGoto(&u, u.ufillast+1, &flag ). Record numbers do not have to be sequential; there can be holes in the database. If a database contains records 1, 2, 3, 5, 7 and the current record number is 2 then a DbSkip(&u, 3, &flag) will seek to record 7. By way of example, the following exemplary implementation of DbGoto is suitable for databases without holes and lazy seeking:
DbMode tells the database engine what kind of database accesses to expect, i.e., sequential forward, sequential backward, or random. DbMode allows the database engine to make a note, for its internal purposes, of what kind of database accesses can be expected in the immediate future. The database engine can alter its buffering strategy accordingly. An exemplary prototype for the call is:
An exemplary use of the function includes:
As shown, DbMode is called with a pointer to a USEDATA structure and a specified mode. In an exemplary embodiment, Mode may be defined as:
DbLoad inputs the Current Record from the record number of the database file (given by usedata.urecnum). The call converts data types from foreign types to the best host equivalents. An exemplary prototype for the call is :
An exemplary use of the function includes:
As shown, DbLoad is called with a pointer to a usedata structure.
DbSave, the counterpart to DbLoad, writes the current record to the database file at the urecnum. An exemplary prototype for the call is:
An exemplary use of the function includes:
The call writes the current record to the database file at the location record number location (given by usedata.urecnum). It converts host data types to their foreign equivalent values in the underlying database system. If the database file supports the deleted records then ud.udelete recorded in the database along with the current record. DbSave can only be used to save existing records. It can not be used to add new records to the file. DbSave is called with a pointer to a USEDATA structure.
DbAppend appends the Current Record to the end of the database file. DbAppend resembles DbSave, except that it adds new records to the database. In an exemplary implementation, DbEof is called before calling DbAppend. DbAppend will adjust ud.ufilsize. An exemplary prototype for the call is:
An exemplary use of the function includes:
As shown, DbAppend is called with a pointer to a USEDATA structure.
DbTruncate truncates a database file at a given record number. An exemplary prototype for the call is:
An exemplary use of the function includes:
As shown, the function receives a pointer to a USEDATA structure and a record number. In turn, it updates ud.ufilsize to the new value of number of records in file; the current record number (i.e., usedata.urecnum) is not updated. If successful, the call returns 0; otherwise an error number (e.g., for "record out of range") is returned.
Error Handling considerations
As described above, the data engine reports error conditions which it encounters by means of the error number returned as the function result. These include errors returned by calls to host services, which the data engine propagates back to the client. In cases where it is inconvenient to return an error code (e.g., the data engine is deeply nested in functions), a special error call (DbError) may be invoked to return the error code and control back to the client.
Data engine assumes responsible for proper clean up when errors occur. An operation must either succeed entirely or the database is left in its state just prior to the call to the data engine. Operations are atomic in a transaction processing sense. Operations either succeed or fail. If they succeed, the state of the database may be altered. If they fail, the state of the database is unchanged. The data engine should track what of its current state (e.g., what data structures have been allocated, what files have been opened, and the like) in order to correctly handle a DbClose (or possibly a DbCleanUp) operation.
Method of Data Access with Dynamically-loaded Drivers
Referring now to FIG. 4, a method 400 of the present invention for data access with dynamically-loaded drivers is illustrated. The method proceeds as follows. At step 401, the method receives a request for a data object of interest. At step 402, the request is passed to the drivers. At step 403, if a particular driver is found which is appropriate for accessing the data object, then that driver is selected at step 404. Otherwise (no at step 403), the method will proceed to select the default driver as the preferred driver for processing the data object at step 405.
At step 406, the selected driver is loaded (into system memory). At step 408, the data engine registers callbacks (pointer to functions within the data engine) with the loaded driver, so that the driver may invoke desired services of the data engine. At step 409, the method processes data access requests (e.g., for information retrieval, sorting, and the like) through the driver. At step 410, the driver is removed from system memory when the foreign data object(s) is no longer of interest (i.e., all operations completed).
An exemplary use of the system for accessing foreign data will now be illustrated with reference to FIG. 5. As shown in the figure, the client is an Xbase client 510 (i.e., supports dBASE-compatible syntax). Through the client, the user has requested access to a 1-2-3 spreadsheet file. Moreover, the user desires the following action: index on A to my.sub.-- index. As described by the method 400 of FIG. 4, the requested data object 551, a spreadsheet file, invokes the spreadsheet driver (.WK1) for the system, shown here as driver 520. The requested action is passed to the data driver for action. The driver determines from its own stock of methods whether it can appropriately process the request. The requested action (indexing) for the example at hand, however, is one more commonly associated with database, not spreadsheet, files. As shown by the methods of the driver 520, therefore, no method for indexing the spreadsheet exists.
Since the preferred driver cannot appropriately handle the requested task, the driver passes the request to the default driver 530. The default driver, like other drivers, includes various methods for manipulating data objects. As shown in this example, the default driver includes a method which is capable of performing the desired task (creating a dBASE-compatible index on a data object). Thus, the method of the default driver is invoked.
Like the other drivers, the default driver may offload much of its processing burden onto the data engine 540. Specifically, the data engine includes services which support core operations for data objects, including file input/output, memory management, conversion routines, exception handling, and the like. For the example at hand, the invoked method of the default driver calls the file's I/O module of the data engine 540 for performing such tasks as reading the data object 551 and writing a new index file 553. As shown, the previously-described USEDATA data structure serves as an intermediary between the system and the data object.
Referring now to FIGS. 6A-D, the system of the present invention will be contrasted against the prior art system of FIG. 1. As shown in FIG. 6A, system 600a includes a client 610, a data engine 620, and drivers 640. The drivers 640 allow the system 600a to concurrently access data objects, including foreign ones. Specifically, drivers 640 include a driver, for accessing data tables 623, 625, 627, and a driver.sub.2 for accessing data table 37 (and data tables 35, 33). As shown in the figure, data tables 623, 625, 627 and data tables 33, 35, 37 represent shared information tables, such as may be stored on the client/server network system 250 (of FIG. 2D).
FIG. 6B shows the system 600b, a system similar to the system 600a with the following exception. The data table 37 is concurrently accessed through a telecommunication medium (e.g., modem), instead of on a network. To achieve this functionality, the system 600b need only employ a different driver (driver.sub.3), which is a driver designed for telecommunication access of data objects.
In FIG. 6C, the system 600c is similar to that of system 600b, except as follows. The data space where the shared tables reside may in fact be any medium. More particularly, the system 600c views the tables as existing in a virtual data space. The client 610 need not have any knowledge of the medium. Instead, any media specific details required by the virtual data space are encapsulated within a driver. The driver, in turn, will be loaded (at runtime) only when access to its type of data object is required. FIG. 6D illustrates the configuration of the system when multiple drivers are simultaneously loaded, whereby concurrent access to multiple foreign data objects (including ones of different format) is provided.
Table 1 demonstrates assembly source code listings, which provide a description of the invention suitable for use in a general purpose digital computer system, such as an IBM-compatible personal computer. A suitable compiler and linking for the code is available from several vendors, include Borland International of Scotts Valley, Calif.
While the invention is described in some detail with specific reference to a single preferred embodiment and certain alternatives, there is no intent to limit the invention to that particular embodiment or those specific alternatives. Thus, the true scope of the present invention is not limited to any one of the foregoing exemplary embodiments but is instead defined by the following claims.
Claims
What is claimed is:
1. In a computer system, a method for accessing data stored in a variety of formats, the method comprising: providing an interface for receiving client requests for access to data stored in a variety of formats; providing a plurality of drivers for accessing data stored in a variety of formats, each driver including method steps providing native access to a data file of a particular format, said plurality of drivers including a subset of one or more drivers that support a particular operation; receiving at said interface a request for access to a particular data file; in response to said request for access, successively invoking each of said drivers until a particular driver is located which includes method steps providing native access to said particular data file; accessing said particular data file using said method steps providing native access to said particular data file; receiving at said interface a request to perform said particular operation on said particular data file; and if said particular driver does not support said particular operation on said particular data file, passing said request to perform said particular operation to one of said subset of drivers that support said particular operation.
2. The method of claim 1, wherein said interface includes a database client interface and wherein said particular data file includes an electronic spreadsheet file.
3. The method of claim 1, wherein said interface includes an electronic spreadsheet interface and wherein, said particular data file includes an electronic database file.
4. The method of claim 1, wherein said method steps providing native access to said particular data file includes steps for opening the data file.
5. The method of claim 4, wherein said steps for opening the data file includes steps for opening the data file in a shared access mode, so that the data file can be accessed concurrently among multiple clients.
6. The method of claim 1, wherein said method steps providing native access to said particular data file include steps for retrieving a particular data record from the data file.
7. The method of claim 1, wherein said method steps providing native access to said particular data file includes steps for locking at least a portion of the data file, so that said data access includes exclusive access to at least a portion of the data file.
8. The method of claim 1, further comprising: receiving at said interface another request for access to another data file, said another data file being stored in a format different from that of said particular data file; successively invoking each of said drivers until a particular driver is located which includes method steps providing native access to said another data file; and accessing said another data file using said method steps providing native access to said another data file.
9. The method of claim 8, further comprising: while the particular data file and said another data file are being accessed, receiving a request at the interface for performing a join operation on the data file; and using said drivers for accessing individual files of each data file for joining the two data files, so that data files of different formats can be joined.
10. The method of claim 1, further comprising: providing a default driver including method steps providing native access to a data file of a generic format; and wherein said method further comprises: if a particular driver cannot be located which includes method steps providing native access to said particular data file, accessing said particular data file using said default driver.
11. In a data processing system, a method for accessing data objects of unknown type stored at a remote system, the method comprising: providing at a local client an interface for requesting access to data objects; storing a plurality of drivers for accessing remote data objects, each driver including knowledge of how to communicate with a remote system and including knowledge of how to access the data objects stored at the remote system, said plurality of drivers including a default driver; receiving at the interface a request for access to a particular data object which is stored at a particular remote system; invoking each driver in turn until a particular driver indicates that it is able to successfully communicate with the particular remote system and it is able to access the particular data object which is stored at the particular remote system; providing access to the particular data object using said particular driver; receiving at the interface a request to perform a particular operation on the particular data object; and if said particular driver does not support said particular operation on the particular data object, passing said request to perform said particular operation to said default driver.
12. The method of claim 11, wherein said remote system includes a remote computer system connected to said computer system through a telecommunication network.
13. The method of claim 11, wherein said data access includes shared access with data integrity maintained.
14. The method of claim 11, wherein said data access includes exclusive access.
15. The method of claim 11, wherein said particular data object comprises a spreadsheet data file and wherein said invoking step comprises: invoking each driver until a driver is invoked which is able to access a spreadsheet data file correctly.
16. In a computer system, a method for providing data access to data objects with dynamically-loaded drivers, the method comprising: receiving a request for access to a data object of interest; communicating the request for access to a driver manager; until a driver is found which provides appropriate access to the data object of interest, loading by the driver manager each driver in turn and attempting to access the data object with the driver; if no driver is found which provides appropriate access to the data object of interest, loading a default driver for providing access to the data object of interest; providing access to the data object of interest with the driver which is loaded for providing access to the data object of interest; receiving a request to perform a particular operation on the data object of interest, the particular operation being supported by a subset of one or more of said dynamically loaded drivers; and if the driver which is loaded for providing access to the data object of interest does not support the particular operation on the data object, performing the particular operation on the data object of interest with one of said subset of drivers that support the particular operation on the data object.
17. The method of claim 16, further comprising: providing a data base engine with core services for accessing data objects of a variety of types; registering call backs to said core services with the loaded driver; and accessing the data object of interest by calling back into said core surfaces for data access operations which are not supported by the loaded driver.
18. The method of claim 16, wherein said dynamically-loaded drivers include selected ones of a spreadsheet file driver and a database file driver.
19. The method of claim 18, wherein said particular data object is a spreadsheet file and wherein only said spreadsheet file driver remains loaded during access to the data object of interest.
20. The method of claim 16, wherein said dynamically-loaded driver includes a spreadsheet file driver, the driver including functionality for processing spreadsheet data files selected from Quattro Pro, Lotus 1-2-3, and Microsoft Excel data files.
21. The method of claim 16, wherein said data access includes access operations for information retrieval, storage, and sorting.
22. The method of claim 16, further comprising: unloading the dynamically-loaded driver after access to the data object of interest ceases.
23. The method of claim 16, wherein each driver includes functionality sufficient for providing access to a particular type of data object without employing said data object.
24. The method of claim 16, further comprising: receiving a request for access to another data object of interest while said data object of interest is being accessed; and until a driver is found which provides appropriate access to said another data object of interest, loading each driver in turn and attempting to access said another data object with the driver.
25. The method of claim 24, wherein said data object of interest and said another data object of interest are different types of data objects.
26. The method of claim 16, wherein said subset of drivers that support the particular operation includes the default driver.
27. In a computer system, a method for providing format-independent access to different data objects, the method comprising: providing a database interface and a default database file driver; receiving at the interface a request for access to a particular data object, said particular data object comprising a spreadsheet data file; passing said request for access to the particular data object to a spreadsheet data file driver, said spreadsheet data file including knowledge of how to access the spreadsheet data file; receiving at the interface a request to perform a database sort operation on the particular data object; attempting to sort the particular data object by passing the request to perform a database sort operation to the spreadsheet data file driver; and if said spreadsheet data file driver does not include knowledge of how to sort the spreadsheet data file, passing the request to perform a database sort operation to said default database driver.
28. The method of claim 27, wherein said request for access includes a dBASE-compatible command to open the spreadsheet data file, said spreadsheet data file being a Lotus 1-2-3 compatible spreadsheet data file, and wherein the request for sorting said spreadsheet data file includes a dBASE-compatible command which creates an index for sorting the spreadsheet data file by a particular field of the spreadsheet data file.
Patent Citations (9)
| Patent | Date | Inventor | Cited By |
|---|---|---|---|
| US4754428 | 1988-06-01 | Schultz et al. | |
| US4811207 | 1989-03-01 | Hikita et al. | |
| US5210824 | 1993-05-01 | Putz et al. | |
| US5212787 | 1993-05-01 | Baker et al. | |
| US5226161 | 1993-07-01 | Khoyi et al. | |
| US5369778 | 1994-11-01 | San Soicie et al. | |
| US5416917 | 1995-05-01 | Adair et al. | |
| US5475836 | 1995-12-01 | Harris et al. | |
| US5630076 | 1997-05-01 | Saulpaugh et al. |
Non-Patent Literature (3)
- Gillespie, "New Standards Promise Open Database Access," Data Based Advisor, Dec. 1992, pp. 89-93.
- Burgess, "For the Records: Database Spoken Here," Windows Tech Journal, Jan. 1993, pp. 271-274.
- Udell, "Beyond DOS: Connecting Windows to Data with ODBC," BYTE, Jan. 1993, pp. 271-274.