Search code examples
databasedatabase-schemacatalog

What is the usage of catalog in Database? what would happen if our database didn't have catalog?


So i know that catalog is the place that contains information about the database and tables and such, but i don't understand what is the usage of this? like if our database didn't have Catalog then what would happen?

Also two other questions about catalogs:

1.does Catalog increases the speed of queries?

2.does it have anything to do with data Independency?


Solution

  • The catalog indeed stores all the data of the database such as the structure of each file, the type and storage format of each data item and various constraints on the data. All this data is called meta-data.

    The catalog is required by most database systems, because the system refers to the catalog to retrieve the structure of the database and interpret the user's queries.

    Specific systems do not require that meta-data, they are known as NOSQL-systems. The data in such systems is stored as self-describing data that includes data item names and data values in one structure.

    Additional questions

    1. The whole database system refers to the catalog all the time, as you can see on the image below. For example when a user enters a query, that query is first compiled and than goes to the query optimizer. The query optimizer is concerned with the rearrangement and possible reordering of operations, elimination of redundancies and use of efficient search algorithms during execution. This optimized query than moves on to the Runtime Database Processor that executes the query and in doing so uses the catalog. It can also store data like statistics to the catalog and it does a lot of other things outside the scope of this question. In general you can indeed say that the use of a catalog increases the speed of the queries (at least in big databases with a lot of data).

    Component modules of a DBMS and their storage interactions

    1. The catalog itself has nothing to do with the concept of data independency itself. However, when using a multiple-level database management system, the catalog must also store the information on how to map requests and data among the various levels. For example (in a three-schema architecture as showed in the image below), if the user uses it's on specific view and writes a query for this view, the query must be mapped to a new query for the whole conceptual schema, which in turn must be mapped to be used with the internal schema and retrieve the stored data.

    Three-schema architecture

    I hope this helps!

    (Images from this blogpost, which sums up a lot of useful information on this topic)