In a relational database management system (RDBMS), data storage and management is organized through various layers of logical units.
Understanding these units is crucial for grasping how data is physically stored and accessed.
Here is a breakdown of the concepts mentioned:
- A table space is a logical container for data files in an RDBMS. It acts as a grouping mechanism for related data, allowing for better organization and management.
- Each table space can have multiple data files, which are the actual physical files that store the data on disk.
- Table spaces can be created, dropped, and resized to manage storage space efficiently.
- Different table spaces can have different properties, such as storage location, performance characteristics, and backup schedules.
- A segment is a collection of logically contiguous extents within a specific table space.
- Each segment belongs to a single table or index, and its size depends on the data contained.
- Segments are used to group related data together and improve performance by minimizing disk access.
- There are different types of segments, such as data segments, index segments, and rollback segments.
- An extent is a contiguous set of data blocks allocated within a table space.
- It is the smallest unit of storage space that can be allocated to a segment.
- The size of an extent is typically predetermined and depends on the database configuration.
- Extents are allocated automatically as needed to accommodate growth in segment size.
- A block is the smallest unit of storage space in an RDBMS.
- It is a fixed-size unit, typically ranging from 4KB to 8KB, depending on the database.
- Blocks are the building blocks of data storage and contain the actual data values.
- Data within a segment is stored and accessed in terms of blocks.
Here’s a simple analogy
- Imagine a bookshelf (table space) holding books (segments).
- Each book is divided into chapters (extents), and each chapter is further divided into pages (blocks).
- The bookshelf helps organize the books, chapters group related content, and pages contain the actual text.