Transcript for:
Oracle Database Architecture: Files and Relationships

Having understood about the basic architecture about an Oracle database, we will move into a little more details about the files and their relationship. A database can be looked at from two perspectives. One is the physical perspective, the other is a logical perspective. Physically, a database is a bunch of files. We've already seen we have data files, read-alog files, and control files. Control files contain metadata about the structure of the database, things like database name, what are the different files, read-a-log files and data files that are part of the database, and the control file is read at the time of mount of an instance. Read-a-log files are logically grouped into read-a-log groups, which also we've seen when we looked at the video on read-a-logs. And the third physical file is that of data files and here we're going to understand how it works. So on the logical side, from a perspective of data files, a database is made up of table spaces. Tablespace contains data files. So whenever you create a tablespace, you'll end up creating the data files, or after having created a tablespace, you can add data files to it. A given data file can belong only to one particular tablespace, whereas one given tablespace can have one or more data files as part of it. Inside a table space, in a logical perspective, we have segments. Segment is a logical grouping that is available within the database to store space for objects you create, like indexes, tables, and other objects. We look at the different types of objects in another video. Segments are further divided into extents. What is an extent? An extent is a contiguous bunch of blocks. And we now have the last layer which is block. From an Oracle database perspective, we have data blocks, which you could specify at the time of a database creation, what is the size of the database block. It could be 2K, 4K, 8K, 16K or 32K. Five different default block sizes. For a given database, one of these could be chosen as the block size. Which block size is good under what circumstances? We'll talk about that later. But basically, whenever you create a database, you specify the default database block size as one of these five sizes. The data file which is present at the physical layer or the physical file is belonging to table space. So from the table space we have data files and data files are made up of OS blocks or operating system blocks. The data block at an Oracle database level is one or more operating system blocks which are part of the data file. So an Oracle database block can be related to physically one or more operating system blocks. So thereby data blocks make up the relationship with the physical data file. An extent which is the layer above the database block is a contiguous chunk of Oracle blocks which means One extent can be present only on one data file. A segment is a collection of extents. Which means a segment could have one or more extents. And each extent could be belonging to a different data file. A segment belongs to a table space. Which means when you create a segment, you specify on which table space you want the segment to be created. If the segment has to grow or rather if the segment needs more space, it has to allocate more extents. Depending on the space available on the files, the extent could be created on different data files which belong to the same table space. If you look at the overall hierarchy, we have a database. From a logical perspective, a database is made up of tablespaces. Tablespace contains segments. Segments contain extents. And extents are contiguous oracle blocks. An oracle block is a set of OS blocks on the data file. Also, a tablespace is made up of one or more data files. A given data file can belong only to one tablespace, whereas one tablespace can have one or more data files. This is the entire listing of the storage structure from a physical layer, which is data files and database, and logical layer where in a database we have tablespace, segment, extends, and blocks.