RELATIONAL DATABASES
o A relational database is based on the relational model and uses a collection of tables to
represent both data and the relationships among those data.
o It also includes DML and DDL.
Tables:
o A table has multiple columns (attributes), each with a unique name
o Tables consist of records structured in a fixed format
o The relational model is a type of record-based model
DATA DEFINITION LANGUAGE (DDL)
o A language used to define the database schema and specify other properties of the data.
o DDL allows specification of:
Database schema (tables, columns, data types)
Storage structure & access methods
Integrity constraints (e.g., domain rules, referential integrity, assertions)
Access authorizations (read, insert, update, delete permissions)
o DDL statements update the data dictionary , which stores metadata (data about data)
Example:
create table department ( dept_name char(20), building char(15),budget numeric(12,2));
o This creates a table with three columns: dept_name, building, and budget
o Each column has a specific data type
DATA MANIPULATION LANGUAGE (DML)
o Used to access and modify data in the database.
o Common operations: Retrieve, Insert, Delete, Update data.
o Two types:
Procedural DML: Specifies what data and how to retrieve
Declarative DML: Specifies what data is needed, not how
o DML also known as query language.
o SQL is the most widely used DML.
DATABASE ACCESS FROM APPLICATION PROGRAMS
o SQL alone cannot handle tasks like input/output or network communication.
o Such tasks are handled through application programs written in host languages like C,
C++ or Java with embedded SQL.
How SQL is Used in Applications
Using APIs
• Example: ODBC (C), JDBC (Java) send SQL queries and get results.
Embedded SQL
• SQL statements are embedded in code and processed by a DML precompiler.
ALAGAPPA CHETTIAR GOVERNMENT COLLEGE OF
ENGINEERING AND TECHNOLOGY
(An Autonomous Institution Affiliated to Anna University)
DEPARTMENT OF COMPUTER SCIENCE
AND ENGINEERING
DATABASE MANAGEMENT SYSTEMS (22CSC32)
TOPIC : RELATIONAL MODEL
GIVEN BY
S. SYED SUHAILA
ASSISTANT PROFESSOR-CSE
ACGCET-KARAIKUDI-630003
RELATIONAL MODEL
• A data model provides tools to describe data, relationships, semantics, and
constraints.
• The relational model uses tables (relations) to represent data and their
relationships.
• Known for its conceptual simplicity, it is the most widely used model in
commercial database systems.
• It focuses on the logical and view levels, hiding low-level storage details.
STRUCTURE OF RELATIONAL DATABASE
• A relational database consists of a collection of tables.
• Each relation (table) is identified by a unique name and consists of:
Attributes – each with a defined domain.
Tuples – each represents a relationship among values.
• The order of tuples is irrelevant , they may be stored in any sequence.
• The term “ relation instance ” refers to a specific instance of a relation i.e.,
containing a specific set of rows.
EXAMPLE OF INSTRUCTOR RELATION
TABLE
(RELATION) COLUMNS
(ATTRIBUTES)
ROWS
(TUPLES)
RELATION
INSTANCE
ATTRIBUTES
• The set of allowed values for each attribute is called its domain.
Eg: The salary attribute in the instructor table has a domain of numeric values like ₹60,000, ₹90,000
• Attribute values are normally required to be atomic (i.e., indivisible).
Eg: Atomic Value: phone_number = 9876543210 (Stored as a single, indivisible value )
Not Atomic: phone_number = (98765, 43210) (Split into subparts like area code and number)
• The special value null is part of every domain and indicates a missing or unknown value.
Eg: If an instructor has no phone number, the phone_number attribute may be null
• Null values can cause complications in the definition of many operations.
DATABASE SCHEMA
• Database schema – The logical structure of the database.
• Database instance – A snapshot of the data in the database at a specific point in time.
• Relation schema – Lists the attributes and their domains.
• Relation instance – The actual data (rows) of a relation at a given moment.
• Example:
Schema : department (deptname , building , budget)
Instance :
SCHEMA DIAGRAMS
A database schema, along with primary key and foreign key dependencies, can
be depicted by schema diagrams.
It shows:
• Relations (tables) as boxes.
• Attributes listed within each box.
• Primary keys are underlined.
• Foreign key dependencies appear as arrows from the foreign key attributes of
the referencing relation to the primary key of the referenced relation.
SCHEMA DIAGRAM EXAMPLE
RELATIONAL QUERY LANGUAGES
• A query language is a language in which a user requests information from the database.
• It works at a higher level than normal programming languages.
• Two types of query languages:
Procedural – tells how to get the data.
Nonprocedural – tells what data is needed, not how to get it.
• Other formal languages:
Relational Algebra (procedural)
Tuple Relational Calculus (non-procedural)
Domain Relational Calculus (non-procedural)
THANK YOU