0% found this document useful (0 votes)
2 views11 pages

Unit 1 Half

Data abstraction in database management systems (DBMS) simplifies user interaction by hiding implementation details of data storage and management. It operates at three levels: physical, logical, and view, each serving different user needs and ensuring data independence and security. Additionally, the document discusses schemas and instances in databases, as well as the role of Data-Definition Language (DDL) and SQL in defining and managing database structures.

Uploaded by

shiwanibwn1999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

Unit 1 Half

Data abstraction in database management systems (DBMS) simplifies user interaction by hiding implementation details of data storage and management. It operates at three levels: physical, logical, and view, each serving different user needs and ensuring data independence and security. Additionally, the document discusses schemas and instances in databases, as well as the role of Data-Definition Language (DDL) and SQL in defining and managing database structures.

Uploaded by

shiwanibwn1999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

DATA ABSTRACTION

Definition

Data abstraction is a feature of database management systems

(DBMS) that hides the implementation details of how data is stored

and managed, providing users with a simplified interface. It helps in

separating the physical storage of data from how users interact with it,

ensuring flexibility, simplicity, and security.

LEVELS OF ABSTRACTION
PHYSICAL LEVEL LOGICAL LEVEL VIEW LEVEL
Definition: Definition: Definition:
This is the lowest level of This is the intermediate This is the highest level of
abstraction. It describes only
data abstraction. It level of abstraction. It
part of the database relevant
describes how the data is describes what data is stored to a specific group of users
physically stored in the in the database and the or applications. The view
level simplifies user
database. This includes relationships between the
interaction by hiding the
details like the data files, data without exposing the complexity of the logical
blocks of storage, and physical storage details. schema.
indexing mechanisms.

Key Features: Key Features: Key Features:


• Focuses on the • Represents the logical • Provides multiple

physical structure of the views of the database


to different users or
representation of database.
applications.
data. • Deals with entities,
• Enhances data
• Deals with low-level attributes, and security by restricting
data structures and relationships. access to specific parts
file organization. • Allows modifications of the database.
• Ensures data is at the physical level • Hides both physical

stored efficiently. without affecting the and logical


complexity.
Who Uses It: logical schema
• Used by database Who Uses It: Who Uses It:
administrators • Used by database • Used by end-users
(DBAs) to optimize administrators and interacting with the
storage and retrieval developers to design database through
processes. the schema and application programs
relationships in the or GUI interfaces.
database.
Example: • Example: • Example:
• A table might be o A relational table o A student view

stored as a sequence might be defined might show only


of records in a file, as: the Student table
with specific less with fields like
characters used as Copy code ID, Name, and
delimiters between Instructor(ID: char(5), Courses.
attributes and Name: char(20), o An HR view

records. Dept_name: char(20), might display the


Salary: numeric(8,2)) Instructor table,
o Relationships excluding
such as foreign sensitive fields
keys ensure that like Salary.
data integrity is
maintained, e.g.,
Dept_name in
the Instructor
table must exist
in the
Department
table.

Benefits of Data Abstraction


1. Simplified User Interaction:
o Users can interact with data at the view level without
needing to understand the logical or physical storage.
2. Data Independence:
o Changes at one level (physical or logical) do not affect
other levels, making the system flexible and easier to
maintain.
3. Improved Security:
o By using views, sensitive data can be hidden from
unauthorized users.
4. Scalability:
o Facilitates the efficient handling of large datasets through
optimized storage mechanisms.

INSTANCES AND SCHEMAS IN A DATABASE

What is a Schema?

• Definition:
A schema is the overall structure or blueprint of a database.

o It defines how the database is organized, including tables,


fields, relationships, and data types.

o A schema is static, meaning it does not change frequently


once defined.

What is an Instance?

• Definition:
An instance is the actual data stored in a database at a specific
point in time.

o It represents the current state or content of the database.

o Instances change over time as data is added, updated, or


deleted.
DATA BASE LANGUAGE
What is a Database Language?
A database language is a set of instructions used to define, manage,
and control data in a database. It has two main components:
1. Data-Definition Language (DDL): Used to define the structure
of a database.
2. Data-Manipulation Language (DML): Used to retrieve,
modify, and delete data from a database.
In most databases, DDL and DML are combined into one language,
like SQL (Structured Query Language).

1.4.1 Data-Definition Language (DDL)


What is DDL?
DDL defines the structure of a database. It is used for:
• Creating tables and other database objects.
• Specifying constraints (rules) for data integrity.
• Describing the storage structure of the database.

Key Features of DDL


1. Create Database Structure:
DDL helps define tables and their attributes.
Example:
sql
Copy code
CREATE TABLE student (
student_id INT,
name CHAR(50),
age INT
);
2. Set Rules for Data Integrity:
Ensures data is valid and consistent using constraints like:
o Domain Constraints: Restricts the type of data.
Example:
sql
Copy code
CREATE TABLE student (
student_id INT,
name CHAR(50),
age INT CHECK (age > 0)
);
o Referential Integrity: Ensures relationships between
tables are correct.
Example:
sql
Copy code
CREATE TABLE instructor (
instructor_id INT PRIMARY KEY,
dept_name CHAR(20),
FOREIGN KEY (dept_name) REFERENCES
department(dept_name)
);
3. Store Metadata:
DDL generates metadata (data about data), which is stored in a
data dictionary.
Example: When a table is created, its structure is stored in the
data dictionary.

What Happens When DDL is Executed?


When you run a DDL command (e.g., CREATE TABLE), the
database:
1. Creates the table in the system.
2. Updates the data dictionary with the table's structure.
3. Enforces the defined constraints.

Example of a DDL Command


sql
Copy code
CREATE TABLE department (
dept_name CHAR(20) PRIMARY KEY,
building CHAR(15),
budget NUMERIC(12,2)
);
• Explanation:
o A table named department is created.
o It has 3 columns:
1. dept_name (string, max 20 characters, and the
primary key).
2. building (string, max 15 characters).
3. budget (a number with 12 digits, 2 after the decimal
point).

What are Constraints in DDL?


1. Domain Constraints: Ensure values are valid based on data
type.
Example:
sql
Copy code
age INT CHECK (age > 0); -- Only positive ages allowed
2. Referential Integrity: Ensures foreign key values exist in the
related table.
Example:
sql
Copy code
FOREIGN KEY (dept_name) REFERENCES
department(dept_name);
3. Authorization: Controls user access.
o Example permissions:
▪ Read: View data but cannot edit it.
▪ Insert: Add new data.
▪ Update: Modify existing data.
▪ Delete: Remove data.

1.4.2 SQL Data-Definition Language


SQL integrates DDL and DML. Here’s how DDL works in SQL:
1. Define Tables:
Example:
sql
Copy code
CREATE TABLE course (
course_id INT PRIMARY KEY,
title CHAR(50),
credits INT
);
2. Set Constraints:
Example:
sql
Copy code
CREATE TABLE instructor (
instructor_id INT PRIMARY KEY,
dept_name CHAR(20),
FOREIGN KEY (dept_name) REFERENCES
department(dept_name)
);
3. Modify Tables:
Example:
sql
Copy code
ALTER TABLE course ADD COLUMN duration INT;
4. Delete Tables:
Example:
sql
Copy code
DROP TABLE course;

Summary
• DDL is used to define and enforce the structure of the database.
• It provides constraints like domain constraints (valid data
types) and referential integrity (correct relationships between
tables).
• SQL is a popular database language that integrates DDL and
DML.
Query Language
• A query is a statement requesting information from a database.
• The part of DML used to retrieve data is called a query
language.
o In practice, query language and data manipulation
language are often used interchangeably.
• SQL (Structured Query Language) is the most widely used
query language and is nonprocedural. This means that you
describe the result you want, not the steps needed to get it.

You might also like