Database
A database is a collection of information which is organized for flexible searching and utilization. There are a wide array of databases, from simple examples such as simple tabular collections to much more complex models such as the relational database model.
The types of database are distinguished by many characteristics. One commonly used characteristic is the programming model associated with the database. Several models have been in wide use for some time.
The flat (or table) model is basically a two-dimensional array of data elements, where all members of a given column are assumed to be similar values, and all members of a row are assumed to be related to one another. For instance, columns for name and password might be used as a part of a system security database. Each row would have the specific password associated with a specific user. Columns of the table often have a type associated with them, defining them as character data, date or time information, integers, or floating point numbers.
The network model expands on the flat model by allowing the addition of multiple tables. A table column type can be defined as a reference to one or more entries of a different table. Thus, the tables are related by references, which can be viewed as a network structure. A particular subset of the network model, the hierarchical model, limits the relationships to a tree structure, instead of the more general directed graph structure implied by the full network model.
Relational databases are similar to network databases, in that they can contain several tables. Unlike network databases, however, the relations between tables are not explicitly encoded in the definition of the tables. Instead, the presence of columns whose name and type are identical implies a relationship between the tables. A mathematical model, known as the relational calculus, implies a set of consistent operations that can be performed on such databases. As a result, relational databases can be flexibly reorganized and reused in ways their original designers did not foresee. Many business and personal databases use the relational model, because of this flexibility.
All of these kinds of database can take advantage of indexing to increase their speed. An index is a sorted list of the contents of some particular table column, with pointers to the row associated with the value. An index allows a set of table rows matching some criterion to be located quickly. Various methods of indexing are commonly used, including b-trees, hashes, and linked lists are all common indexing techniques.
In recent years, the object-oriented paradigm has been applied to databases as well, creating a new programming model known as object databases. Objects are very similar to table rows in the other models, and the columns of a table are very similar to the data definitions included as a part of an object class definition (however, polymorphism complicates the object model because clients in general only have access to an abstract pointer to an object to be accessed; in other words, unlike the well-defined tabular relational model, in the object model the application program does not know the concrete type of the objects it is accessing). In addition, the object database can in some cases include stored behaviors, which can be triggered when operations are performed on the object. However, this is not always the case; having object behaviors stored in the database requires maintaining two sets of code: the application code, and the database code. Another approach is merely to store object fields in the database, requiring instantiation of the actual objects within the memory space of the application program before the methods (behaviors) of the object can be accessed (which also raises consistency issues when multiple clients, written in different languages, access objects in the database).
Object databases and relational databases have become very similar over time, and object systems today are often implemented atop a relational database foundation (called object-relational databases). Nonetheless, there is always a fundamental impedance mismatch between the object and relational data models, so object-relational databases require object-relational mapping software to map between the relational model (row-oriented, ad-hoc querying) and the object-oriented model (polymorphic types, navigational traversal of objects). This mapping always introduces inefficiency, but may be the only choice for many systems which mandate a relational database back-end (for legacy reasons). Note that writing object-relational mapping software is a non-trivial task due to the polymorphic nature of containers in the object paradigm; in other words, it is not as simple as "take all fields in a record, copy them into the object, and voila! you're done." Due to polymorphism, traversing a link (abstract pointer) to an object or issuing an query on an abstract type returns an object whose concrete type must be known to the relational database back-end (so it can actually cause the construction of the appropriate concrete type and all of the concrete fields) whereby the application program only knows the abstract type (and therefore has access only to the fields and methods defined in the abstract parent class, but is guaranteed polymorphic behavior late binding on the concrete object accessed through the abstract pointer). There are several design patterns and research papers on writing object-relational mapping software; additionally, there are many free-software and commercial solutions, with varying degrees of flexibility.
Databases are used in many applications, spanning virtually the entire range of computer software. Databases are the preferred method of storage for large multiuser applications, where coordination between many users is needed. Even individual users find them convenient, though, and many electronic mail programs and personal organizers are based on standard database technology.
See also:
- Database management system
- Database applications (Transaction processing, Data warehousing, etc.)