Database Systems Week 3
Database Systems Week 3
Lecture # 6
Instructor
Amna Zulfiqar
Data Models
● a collection of concepts that can be used to describe
○ the structure of a database (data types, constraints,
relationships)
○ the operations for manipulating this structure
● Most data models also include a set of basic operations for
specifying retrievals and updates on the database.
● Some data models allows a database designer to specify the
dynamic aspect or behavior of a database application
Categories of Data Models
● High-level or conceptual or semantic data models
provide concepts that are close to the way many users
perceive data
○ entities, attributes, and relationships based
○ Object based data model
● Low-level or physical or internal data models provide
concepts that describe the details of how data is stored on
the computer storage media
○ represents information such as record formats, record
orderings, and access paths
Categories of Data Models
● Implementation or Representational data models
provide concepts that may be easily understood by end
users but that are not too far removed from the way data is
organized in computer storage
○ these models are most frequently used in traditional
commercial DBMSs (relational data model, the network and
hierarchical models)
● Self-describing data models combines the description of
the data with the data values themselves.
○ These models include XML as well as many of the key-value
stores and NOSQL systems
A collection in MongoDB (Self describing data model) will look like this:
{
"_id": ObjectId("507f191e810c19729de860ea"),
"name": "Alice Johnson",
"age": 22,
"major": "Computer Science",
"enrollmentDate": "2023-09-01"
}
Schemas
● description of a database
● It is specified during database design and is not expected to
change frequently.
● Schema Diagram: a displayed schema.
○ The diagram displays the structure of each record type
● Each object in the schema—such as STUDENT or COURSE—a
schema construct.
Schema Diagram
Database State
● Data in the database at a particular moment in time is called a
database state or snapshot
○ current set of occurrences or instances in the database.
● In a given database state, each schema construct has its own
current set of instances;
● Example, the STUDENT construct will contain the set of
individual student entities (records) as its instances.
● Every time we insert or delete a record or change the value of a
data item in a record, we change one state of the database into
another state.
Database State
Database schema vs Database state
● When we define a new database, we specify its database schema
only to the DBMS.
○ the corresponding database state is the empty state with no
data.
● We get the initial state of the database when the database is first
populated or loaded with the initial data.
○ From then on, every time an update operation is applied to the
database, we get another database state.
● The DBMS is partly responsible for ensuring that every state of the
database is a valid state
● The schema is sometimes called the intension, and a database
state is called an extension of the schema.
Schema Evolution
Changes occasionally need to be applied to the schema as the
application requirements change.
Example:
● add new columns to a certain relation, or split it into several
subrelations,
● as long as the user views still produce the same result as
before, the users and applications that access the data through
these views will not notice the change in the logical data
model.
Physical Data Independence
Capacity to change the internal schema without having to change the
conceptual schema.
UPDATE Employees
SET Salary = Salary * 1.10
WHERE EXTRACT(YEAR FROM AGE(HireDate)) > 5;