Data Models, Schema, and Instances
Data Model
A data model is a collection of concepts used to describe the structure of a database and play a central role in supporting data abstraction. Provides a formal framework for describing data, data relationships, organizing, representing, and manipulating data and consistency constraints.
Data Abstraction : refers to the suppression of unnecessary details of data organization and storage, and the highlighting of essential features for an improved understanding of data. Different users can perceive data at their preferred level of detail.
Categories of Data Models
Many data models have been proposed, which can be categorized according to the types of concepts they use to describe the database structure:
High-level (conceptual) data models: Provide concepts that are close to the way users perceive data. These models are used during the early phases of database design and include concepts like entities, attributes, and relationships.
Low-level (physical) data models: Describe the details of how data is stored on the computer storage media, typically magnetic disks. These models include information such as record layouts, storage structures, and access paths. They are intended for use by system programmers and database administrators.
Representational (implementation) data models: Provide concepts that are easily understood by end users and are also close to the way data is physically stored. These models hide many storage details but can be implemented directly on a computer system. They are most commonly used in commercial DBMSs.
Components of a Data Model
Structural Component:
Defines how data is organized in the database. This includes:Data types
Entity: Represents a real-world object or concept, such as an employee or project.
Attribute: Represents a property or characteristic of an entity, such as name or salary.
Relationship: Represents an association among two or more entities.
Constraints (such as keys, cardinality, and data integrity rules)
Manipulative Component:
Specifies the operations that can be performed on the data. These include:Basic operations such as insert, delete, update, and retrieve
Query languages (e.g., SQL for relational databases)
Advanced or user-defined operations depending on the model (e.g., traversals in graph databases)
Dynamic or Behavioral Component (in some models):
Defines how the database can evolve over time. This includes:Triggers
Rules
User-defined procedures or operations
Support for modeling workflows or application-specific behaviors
Different data models offer different levels of abstraction and are suited to different types of applications.
Examples of Common Data Models
Entity-Relationship (ER) Model: A high-level conceptual model used in database design.
Relational Model: Uses tables (relations), rows (tuples), and columns (attributes). The most widely used model in commercial DBMSs.
Object-Oriented Model: Represents data as objects, similar to object-oriented programming.
Document Model: Stores data in document formats (e.g., JSON, XML). Used in NoSQL systems.
Graph Model: Represents data as nodes and edges. Useful in applications like social networks and recommendation systems.
Key-Value Model: Simplest form of NoSQL database, where each item is stored as a key-value pair.
Schemas, Instances, and Database State
In a data model, it is important to distinguish between the description of the database and the actual data stored in it.
Schema
A schema refers to the overall design or description of a database. It defines the database's structure, data types, relationships, and consistency constraints. Acts as a blueprint for how the data is organized.
- The schema is specified during the database design phase and is not expected to change frequently.
- Each object in the schema—such as STUDENT or COURSE—is called a schema construct.
Instance
Database state (or instance), reflects the collection of information stored in the database at a particular moment in time and changes frequently as data is inserted, deleted, or modified to reflect changes in the real-world aspect it represents.
Many database states can exist for a single database schema. When a new database is defined, its initial state is typically empty, and it becomes populated with initial data.
The DBMS is responsible for ensuring that each instance of the database conforms to the constraints and structure defined in the schema. This ensures that every state of the database is valid.
The DBMS stores the descriptions of schema constructs and constraints (metadata) in its catalog, allowing the DBMS software to refer to the schema whenever needed to validate the database state. The schema is sometimes referred to as the "intension," and a database state as an "extension" of the schema.