SlideShare a Scribd company logo
1 of 65
INTRODUCTION
UNIT I - RELATIONAL DATABASES
Purpose of Database System - Views of data –
Database Languages - Database Architecture -
Introduction to Relational Model - Structure of
Relational Databases - Database Schemas – Keys -
Schema Diagrams - Relational Query Languages -
Relational Operations - Instruction to SQL - Accessing
SQL from a programming language
What is Data?
In simple words, data can be facts related to any object
in consideration. For example, your name, age, height, weight,
etc. are some data related to you.
A picture, image, file, pdf, etc. can also be considered
data.
Database
 A database is a collection of related data organized in a way
that data can be easily accessed, managed and updated.
 Database can be a software or hardware based , with sole
purpose of storing data.
Example:
 An online telephone directory uses a database to store data
of people, phone numbers, and other contact details.
 Facebook. It needs to store, manipulate, and present data
related to members, their friends, member activities,
messages, advertisements, and a lot more.
Database Management Systems
Definition:
“A Collection of interrelated data and a set of programs to
access those data”
 Database Management Systems (DBMS) are software systems used
to store, retrieve, and run queries on data. A DBMS serves as an
interface between an end-user and a database, allowing users to
create, read, update, and delete data in the database.
 Example: MySQL, PostgreSQL, Microsoft SQL Server, Oracle
Database, and Microsoft Access
DBMS –Manage the Data
 Who Access the Data
When Access the Data
 How Access the Data
Features :
Security of Data
Durability of Data( ability to withstand)
Isolation of Data(privacy)
Consistency of Data(stable)
Reliability of Data(performs consistently without
causing problems)
Scalability of Data(ability to expand the capacity of a
database system)
Applications
 Banking
 Universities
 Reservation Systems
 Telecommunication
 Library Management System
 Social Media Sites
 Online Shopping
Purpose of Database System
Disadvantages of File System:
Data Redundancy
Data Inconsistency
Difficulty in Accessing Data
Limited Data Sharing
Integrity Problems
Concurrent Access Anomalies
Security Problems
Purpose:
 Storage Store the data in Efficient way so that
retrieval can be made easy
 Security Securing the data or privacy
 Flexibility Small or Huge data
 Reliability Data stored should not be changed
View of data in DBMS narrate how the data is visualized at each level
of data abstraction
Data Abstraction
Data abstraction is hiding the complex data structure in order
to simplify the user’s interface of the system.
Hiding irrelevant details from user and providing abstract view of
data to users, helps in easy and efficient user-database interaction
To ease the user interaction with database, the developers hide
internal irrelevant details from users.
Views of Data
To achieve data abstraction, use Three-Schema architecture which
abstracts the database at three levels.
Three-Schema Architecture:
The main objective -> separation between the user interface and
the physical database.
The three-schema architecture defines the view of data at three
levels:
Physical level (internal level)
Logical level (conceptual level)
View level (external level)
Physical level:
 how data is actually stored in database
Logical level:
 what data is stored in database and what relationships exist
among those data
View level:
 the user interaction with database system.
1. Physical Level/ Internal Level
 how the data is stored in the hardware. It also
describes how the data can be accessed.
The physical level shows the data abstraction at the
lowest level and it has complex data structures.
Only the database administrator operates at this
level.
2. Logical Level/ Conceptual Level
It is a level above the physical level.
 data is stored in the form of the entity set, entities, their data types,
the relationship among the entity sets, user operations performed to
retrieve or modify the data.
As users are restricted to access some particular parts of the database.
It is the developer and database administrator who operates
at the logical or the conceptual level.
3. View Level/ User level/ External level
 It is the highest level of data abstraction and exhibits only a
part of the whole database.
 It exhibits the data in which the user is interested.
 The view level can describe many views of the same data.
 Here, the user retrieves the information using different
application from the database.
Schema and Instances
Schema:
The overall design of the database is called the
database schema.
 Design of a database
 only a structural view(design) of a database.
 The schema for student table
Reg. No Name Marks
Types of Schema:
Physical Schema:
 how the data stored in blocks of storage
Logical schema:
 data can be described as certain types of data records
gets stored in data structures.
View schema or Subschema:
 end user interaction with database systems
A database may also have several schemas at the view
level, sometimes called subschemas, that describe
different views of the database.
Instance:
 The data stored in database may gets changed while inserting
or deleting.
The collection of information at particular moment is called
instance of data.
 The schema for student table
Reg. No Name Marks
1 AAA 410
2 BBB 446
3 CCC 480
Database Languages
Database Languages
 used to read, update and store data in a database.
Types:
 Data Definition Language (DDL)
 Data Manipulation Language (DML)
 Data Control language (DCL)
 Transaction Control Language(TCL)
Insert the Sub Title of Your Presentation
Data Definition Language (DDL):
 Specifying the database schema by a set of definitions.
operations:
 To create the database instance – CREATE
To alter the structure of database – ALTER
To drop database instances – DROP
To delete tables in a database instance – TRUNCATE
To rename database instances – RENAME
To drop objects from database such as tables – DROP
To Comment – Comment
Data Manipulation Language (DML)
 accessing and manipulating data in a database
operations:
To read records from table(s) – SELECT
To insert record(s) into the table(s) – INSERT
Update the data in table(s) – UPDATE
Delete all the records from the table – DELETE
Procedural DML – Require a user to specify what data are needed
and how to get those data.
The procedural DMLs are also called one-at-a-time DMLs as it
retrieves and processes each record separately.
Non Procedural /Declarative DML - Require a user to specify what
data are needed and without specifying how to get those data.
The non-procedural DMLs are also called set-a-time DMLs; this
is because a non-procedural DMLs can retrieve several records
using a single DML command.
Non-procedural DMLs are also called declarative languages.
Data Control language (DCL)
Granting and revoking user access on a database
operations:
To grant access to user – GRANT
To revoke access from user – REVOKE
Transaction Control Language(TCL)
The changes in the database that we made using DML
commands are either performed or rollbacked using TCL
operations:
To persist the changes made by DML commands in database –
COMMIT
To rollback the changes made to the database – ROLLBACK
Database Architecture
Relational DBMS
 Collection of tables having unique names.
RollNo Name Phone
001 AAA 111
002 BBB 222
003 CCC 333
Terms:
• Relation / tables
• Tuple / record / row
• Field / column /
attributes
• Domain
• key
• Degree
• Cardinality
• Relational operations
• Normalization
 Table or relation:
 a collection of data represented in rows and columns
 cannot have duplicate data or rows.
Roll No Name Marks Phone
001 AAA 88 111
002 BBB 83 222
003 CCC 98 333
004 DDD 67 444
 Tuple or record or row
 Each row of a table is known as record
 a set of related data
004 DDD 67 444
 Attribute or columns:
 Each record can be broken down into several small
parts of data.
 Ex: RollNo, Sname, Marks, Phone
 Relation Schema and Instance:
 Schema: structure of the relation
 Instance: a specific set of rows
 Domain:
 a set of permitted values for an attribute in table.
 Example: a set of all possible marks of the students.
 Domain of marks (88,83,98)
Degree:
Total number of columns present in the relational
database
Cardinality:
Total number of rows present in the relational
database
In the above table, degree is 3 and cardinality is 3.
Emp# Job Name Salary
E10 Sales 12500
E12 Null 25000
Primary Key
 a key that can uniquely identify each record in a
table.
Each table must have a primary key.
Primary key should not be NULL.
 Example: student_id
Foreign key
 it is an attribute which establish relationship
between another table.
to point to the primary key of another table.
Parent Table Child Table
Relational Algebra
Operations:
 Selection
 projection
 Cartesian product
 Set Operations
 Join
 Selection (σ)
 to fetch rows or tuple from the table.
 syntax:
σpredicate(relation)
predicate – logic using which the data from the relation is selected.
Ex: Student – Table
Reg. No Sname Age
1 AAA 15
2 BBB 18
3 CCC 16
σage>15(Student)
Instructor
to project only a certain set of attributes of a relation.
 remove duplicate data from the columns.
 Syntax: ΠA1,A2,…(r)
Projection:
Cartesian product:
 to combine data from two different relations into one and fetch
data from the combined relation
Syntax: A x B
Table A1
A B
1 1
2 2
Table B1
C D E
1 2 7
2 6 8
5 7 9
A1 x B1
A B C D E
1 1 1 2 7
1 1 2 6 8
1 1 5 7 9
2 2 1 2 7
2 2 2 6 8
2 2 5 7 9
Set Operations
Union
Intersection
Set difference
Union:
 to fetch data from two relations
 the relations specified should have same number
of attributes and same attribute domain.
 duplicated tuples are automatically eliminated
from the result.
 Syntax: A ᴜ B
Table A1
A B
1 1
1 2
2 1
Table B1
A B
1 2
2 3
A1 ᴜ B1
A B
1 1
1 2
2 1
2 3
Intersection:
 to fetch data from both tables which is common in both
the tables.
Syntax: A ∩ B
Table A1
Name id
aaa 1
bbb 2
ccc 1
Table B1
Name course
aaa C
ccc C++
A1 ∩ B1
Name
aaa
ccc
Set-Difference:
 the result of set difference is tuples, which are present in
one relation but are not in the second relation.
Syntax: A - B
Table A1
A B
1 1
1 2
2 1
Table B1
A B
1 2
2 3
A1 - B1
A B
1 1
2 1
Rename Operation:
 to rename the output relation for any query relation which returns the
result.
Syntax: ρ (RelationNew, RelationOld)
Table A1
A B
1 1
2 2
ρ (A1,B1)
Table B1
A B
1 1
2 2
Accessing SQL From a Programming Language
a database programmer must have access to a general-
purpose programming language for at least two reasons:
SQL does not provide the full expressive power of a
general-purpose language
(C, Java, or Python that cannot be expressed in SQL. To
write such queries, we can embed SQL within a more
powerful language.)
Non declarative actions—such as printing a report,
interacting with a user, or sending the results of a query to
a graphical user interface—cannot be done from within
SQL
Accessing SQL From a Programming Language
Accessing SQL From a Programming Language
To access SQL from other programming languages, we can use:
 Dynamic SQL: JDBC and ODBC
 Embedded SQL
 PHP
 ODBC (Open Database Connectivity) and JDBC (Java
Database Connectivity) serve as APIs for a program to interact
with a database server.
 In general, the application must make calls to:
1.connect with the database server
2.send SQL commands to the database server
3.fetch tuples of result one-by-one into program variables
Dynamic SQL: JDBC and ODBC
To access SQL from other programming languages, we can use:
ODBC
 ODBC works with C, C++, C# and Visual Basic (other APIs such as
ADO.NET sit on top of ODBC).
 ODBC is the standard for application programs communicating
with a database server.
The API will:
1.open a connection with a database
2.send queries and updates
3.get back results
ODBC can be used with applications such as GUIs, spreadsheets etc.
JDBC
 JDBC works with Java.
 Along with supporting various features for querying and updating
data, and for retrieving query results, JDBC also supports metadata
retrieval i.e. retrieving information about the database such as
relations present in the database and the names and types of relation
attributes.
JDBC connects with the database as follows:
1.open a connection
2.create a “Statement” object
3.execute queries using the Statement object to send queries and
fetch results
4.exception mechanism to handle errors
Embedded SQL
 Embedded SQL refers to embedding SQL queries in another
language.
 SQL can be embedded in various languages including C, Java
and Cobol.
 A language into which SQL queries are embedded is referred
to as a host language, and the SQL structures permitted in the
host language comprise embedded SQL.
 The EXEC SQL statement is used to identify embedded SQL
request to the preprocessor:
EXEC SQL <embedded SQL statement> END_EXEC
PHP
 PHP is a server-side scripting language.
 It was mainly developed for the web but can also be used as
a general-purpose programming language.
 PHP works well with MySQL and can be used in combination
with HTML to create a webapp that connects to a database.
PHP
Working:
1.web browser sends HTTP requests and receives HTTP
responses
2.PHP script (on the server-side) connects to DBMS and uses
query results to produce its output
3.web server calls the PHP script and incorporates its output
into the response
4.web browser renders the HTML document from the response
PHP
Executing SQL from PHP:
1.connect to server (mysql_connect)
2.select the database (mysql_select_db)
3.run query
4.retrieve row of results (mysql_fetch_array)
5.retrieve attributes (foreach)

More Related Content

Similar to unit 1.pptx

Database-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptxDatabase-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptxAnmolThakur67
 
Ch-1-Introduction-to-Database.pdf
Ch-1-Introduction-to-Database.pdfCh-1-Introduction-to-Database.pdf
Ch-1-Introduction-to-Database.pdfMrjJoker1
 
Fundamentals of database system - Database System Concepts and Architecture
Fundamentals of database system - Database System Concepts and ArchitectureFundamentals of database system - Database System Concepts and Architecture
Fundamentals of database system - Database System Concepts and ArchitectureMustafa Kamel Mohammadi
 
database introductoin optimization1-app6891.pdf
database introductoin optimization1-app6891.pdfdatabase introductoin optimization1-app6891.pdf
database introductoin optimization1-app6891.pdfparveen204931475
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to DatabaseSiti Ismail
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 
Data abs ind & mod
Data abs  ind  & modData abs  ind  & mod
Data abs ind & modHaider Adnan
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbmsAnjaan Gajendra
 

Similar to unit 1.pptx (20)

Database-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptxDatabase-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptx
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
 
Ch-1-Introduction-to-Database.pdf
Ch-1-Introduction-to-Database.pdfCh-1-Introduction-to-Database.pdf
Ch-1-Introduction-to-Database.pdf
 
Fundamentals of database system - Database System Concepts and Architecture
Fundamentals of database system - Database System Concepts and ArchitectureFundamentals of database system - Database System Concepts and Architecture
Fundamentals of database system - Database System Concepts and Architecture
 
dbms notes.ppt
dbms notes.pptdbms notes.ppt
dbms notes.ppt
 
database introductoin optimization1-app6891.pdf
database introductoin optimization1-app6891.pdfdatabase introductoin optimization1-app6891.pdf
database introductoin optimization1-app6891.pdf
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to Database
 
Dbms notes
Dbms notesDbms notes
Dbms notes
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
Ch09
Ch09Ch09
Ch09
 
data base
data basedata base
data base
 
Unit01 dbms
Unit01 dbmsUnit01 dbms
Unit01 dbms
 
Dbms module i
Dbms module iDbms module i
Dbms module i
 
Dbms Basics
Dbms BasicsDbms Basics
Dbms Basics
 
Database fundamentals
Database fundamentalsDatabase fundamentals
Database fundamentals
 
Data abs ind & mod
Data abs  ind  & modData abs  ind  & mod
Data abs ind & mod
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
 
D B M S Animate
D B M S AnimateD B M S Animate
D B M S Animate
 
23246406 dbms-unit-1
23246406 dbms-unit-123246406 dbms-unit-1
23246406 dbms-unit-1
 

Recently uploaded

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

unit 1.pptx

  • 1.
  • 3. UNIT I - RELATIONAL DATABASES Purpose of Database System - Views of data – Database Languages - Database Architecture - Introduction to Relational Model - Structure of Relational Databases - Database Schemas – Keys - Schema Diagrams - Relational Query Languages - Relational Operations - Instruction to SQL - Accessing SQL from a programming language
  • 4. What is Data? In simple words, data can be facts related to any object in consideration. For example, your name, age, height, weight, etc. are some data related to you. A picture, image, file, pdf, etc. can also be considered data.
  • 5. Database  A database is a collection of related data organized in a way that data can be easily accessed, managed and updated.  Database can be a software or hardware based , with sole purpose of storing data. Example:  An online telephone directory uses a database to store data of people, phone numbers, and other contact details.  Facebook. It needs to store, manipulate, and present data related to members, their friends, member activities, messages, advertisements, and a lot more.
  • 6. Database Management Systems Definition: “A Collection of interrelated data and a set of programs to access those data”  Database Management Systems (DBMS) are software systems used to store, retrieve, and run queries on data. A DBMS serves as an interface between an end-user and a database, allowing users to create, read, update, and delete data in the database.  Example: MySQL, PostgreSQL, Microsoft SQL Server, Oracle Database, and Microsoft Access
  • 7. DBMS –Manage the Data  Who Access the Data When Access the Data  How Access the Data Features : Security of Data Durability of Data( ability to withstand) Isolation of Data(privacy) Consistency of Data(stable) Reliability of Data(performs consistently without causing problems) Scalability of Data(ability to expand the capacity of a database system)
  • 8. Applications  Banking  Universities  Reservation Systems  Telecommunication  Library Management System  Social Media Sites  Online Shopping
  • 9. Purpose of Database System Disadvantages of File System: Data Redundancy Data Inconsistency Difficulty in Accessing Data Limited Data Sharing Integrity Problems Concurrent Access Anomalies Security Problems
  • 10. Purpose:  Storage Store the data in Efficient way so that retrieval can be made easy  Security Securing the data or privacy  Flexibility Small or Huge data  Reliability Data stored should not be changed
  • 11. View of data in DBMS narrate how the data is visualized at each level of data abstraction Data Abstraction Data abstraction is hiding the complex data structure in order to simplify the user’s interface of the system. Hiding irrelevant details from user and providing abstract view of data to users, helps in easy and efficient user-database interaction To ease the user interaction with database, the developers hide internal irrelevant details from users. Views of Data
  • 12. To achieve data abstraction, use Three-Schema architecture which abstracts the database at three levels. Three-Schema Architecture: The main objective -> separation between the user interface and the physical database. The three-schema architecture defines the view of data at three levels: Physical level (internal level) Logical level (conceptual level) View level (external level)
  • 13.
  • 14. Physical level:  how data is actually stored in database Logical level:  what data is stored in database and what relationships exist among those data View level:  the user interaction with database system.
  • 15. 1. Physical Level/ Internal Level  how the data is stored in the hardware. It also describes how the data can be accessed. The physical level shows the data abstraction at the lowest level and it has complex data structures. Only the database administrator operates at this level.
  • 16. 2. Logical Level/ Conceptual Level It is a level above the physical level.  data is stored in the form of the entity set, entities, their data types, the relationship among the entity sets, user operations performed to retrieve or modify the data. As users are restricted to access some particular parts of the database. It is the developer and database administrator who operates at the logical or the conceptual level.
  • 17. 3. View Level/ User level/ External level  It is the highest level of data abstraction and exhibits only a part of the whole database.  It exhibits the data in which the user is interested.  The view level can describe many views of the same data.  Here, the user retrieves the information using different application from the database.
  • 18. Schema and Instances Schema: The overall design of the database is called the database schema.  Design of a database  only a structural view(design) of a database.  The schema for student table Reg. No Name Marks
  • 19. Types of Schema: Physical Schema:  how the data stored in blocks of storage Logical schema:  data can be described as certain types of data records gets stored in data structures. View schema or Subschema:  end user interaction with database systems A database may also have several schemas at the view level, sometimes called subschemas, that describe different views of the database.
  • 20. Instance:  The data stored in database may gets changed while inserting or deleting. The collection of information at particular moment is called instance of data.  The schema for student table Reg. No Name Marks 1 AAA 410 2 BBB 446 3 CCC 480
  • 22. Database Languages  used to read, update and store data in a database. Types:  Data Definition Language (DDL)  Data Manipulation Language (DML)  Data Control language (DCL)  Transaction Control Language(TCL)
  • 23. Insert the Sub Title of Your Presentation
  • 24. Data Definition Language (DDL):  Specifying the database schema by a set of definitions. operations:  To create the database instance – CREATE To alter the structure of database – ALTER To drop database instances – DROP To delete tables in a database instance – TRUNCATE To rename database instances – RENAME To drop objects from database such as tables – DROP To Comment – Comment
  • 25. Data Manipulation Language (DML)  accessing and manipulating data in a database operations: To read records from table(s) – SELECT To insert record(s) into the table(s) – INSERT Update the data in table(s) – UPDATE Delete all the records from the table – DELETE
  • 26. Procedural DML – Require a user to specify what data are needed and how to get those data. The procedural DMLs are also called one-at-a-time DMLs as it retrieves and processes each record separately.
  • 27. Non Procedural /Declarative DML - Require a user to specify what data are needed and without specifying how to get those data. The non-procedural DMLs are also called set-a-time DMLs; this is because a non-procedural DMLs can retrieve several records using a single DML command. Non-procedural DMLs are also called declarative languages.
  • 28. Data Control language (DCL) Granting and revoking user access on a database operations: To grant access to user – GRANT To revoke access from user – REVOKE
  • 29. Transaction Control Language(TCL) The changes in the database that we made using DML commands are either performed or rollbacked using TCL operations: To persist the changes made by DML commands in database – COMMIT To rollback the changes made to the database – ROLLBACK
  • 31.
  • 32. Relational DBMS  Collection of tables having unique names. RollNo Name Phone 001 AAA 111 002 BBB 222 003 CCC 333
  • 33. Terms: • Relation / tables • Tuple / record / row • Field / column / attributes • Domain • key • Degree • Cardinality • Relational operations • Normalization
  • 34.  Table or relation:  a collection of data represented in rows and columns  cannot have duplicate data or rows. Roll No Name Marks Phone 001 AAA 88 111 002 BBB 83 222 003 CCC 98 333 004 DDD 67 444
  • 35.  Tuple or record or row  Each row of a table is known as record  a set of related data 004 DDD 67 444
  • 36.  Attribute or columns:  Each record can be broken down into several small parts of data.  Ex: RollNo, Sname, Marks, Phone  Relation Schema and Instance:  Schema: structure of the relation  Instance: a specific set of rows
  • 37.  Domain:  a set of permitted values for an attribute in table.  Example: a set of all possible marks of the students.  Domain of marks (88,83,98)
  • 38. Degree: Total number of columns present in the relational database Cardinality: Total number of rows present in the relational database In the above table, degree is 3 and cardinality is 3. Emp# Job Name Salary E10 Sales 12500 E12 Null 25000
  • 39. Primary Key  a key that can uniquely identify each record in a table. Each table must have a primary key. Primary key should not be NULL.  Example: student_id
  • 40. Foreign key  it is an attribute which establish relationship between another table. to point to the primary key of another table. Parent Table Child Table
  • 41.
  • 42. Relational Algebra Operations:  Selection  projection  Cartesian product  Set Operations  Join
  • 43.  Selection (σ)  to fetch rows or tuple from the table.  syntax: σpredicate(relation) predicate – logic using which the data from the relation is selected. Ex: Student – Table Reg. No Sname Age 1 AAA 15 2 BBB 18 3 CCC 16 σage>15(Student)
  • 45. to project only a certain set of attributes of a relation.  remove duplicate data from the columns.  Syntax: ΠA1,A2,…(r) Projection:
  • 46.
  • 47. Cartesian product:  to combine data from two different relations into one and fetch data from the combined relation Syntax: A x B Table A1 A B 1 1 2 2 Table B1 C D E 1 2 7 2 6 8 5 7 9 A1 x B1 A B C D E 1 1 1 2 7 1 1 2 6 8 1 1 5 7 9 2 2 1 2 7 2 2 2 6 8 2 2 5 7 9
  • 49. Union:  to fetch data from two relations  the relations specified should have same number of attributes and same attribute domain.  duplicated tuples are automatically eliminated from the result.  Syntax: A ᴜ B
  • 50. Table A1 A B 1 1 1 2 2 1 Table B1 A B 1 2 2 3 A1 ᴜ B1 A B 1 1 1 2 2 1 2 3
  • 51. Intersection:  to fetch data from both tables which is common in both the tables. Syntax: A ∩ B Table A1 Name id aaa 1 bbb 2 ccc 1 Table B1 Name course aaa C ccc C++ A1 ∩ B1 Name aaa ccc
  • 52. Set-Difference:  the result of set difference is tuples, which are present in one relation but are not in the second relation. Syntax: A - B Table A1 A B 1 1 1 2 2 1 Table B1 A B 1 2 2 3 A1 - B1 A B 1 1 2 1
  • 53. Rename Operation:  to rename the output relation for any query relation which returns the result. Syntax: ρ (RelationNew, RelationOld) Table A1 A B 1 1 2 2 ρ (A1,B1) Table B1 A B 1 1 2 2
  • 54. Accessing SQL From a Programming Language
  • 55. a database programmer must have access to a general- purpose programming language for at least two reasons: SQL does not provide the full expressive power of a general-purpose language (C, Java, or Python that cannot be expressed in SQL. To write such queries, we can embed SQL within a more powerful language.) Non declarative actions—such as printing a report, interacting with a user, or sending the results of a query to a graphical user interface—cannot be done from within SQL Accessing SQL From a Programming Language
  • 56. Accessing SQL From a Programming Language To access SQL from other programming languages, we can use:  Dynamic SQL: JDBC and ODBC  Embedded SQL  PHP
  • 57.  ODBC (Open Database Connectivity) and JDBC (Java Database Connectivity) serve as APIs for a program to interact with a database server.  In general, the application must make calls to: 1.connect with the database server 2.send SQL commands to the database server 3.fetch tuples of result one-by-one into program variables Dynamic SQL: JDBC and ODBC
  • 58. To access SQL from other programming languages, we can use:
  • 59.
  • 60. ODBC  ODBC works with C, C++, C# and Visual Basic (other APIs such as ADO.NET sit on top of ODBC).  ODBC is the standard for application programs communicating with a database server. The API will: 1.open a connection with a database 2.send queries and updates 3.get back results ODBC can be used with applications such as GUIs, spreadsheets etc.
  • 61. JDBC  JDBC works with Java.  Along with supporting various features for querying and updating data, and for retrieving query results, JDBC also supports metadata retrieval i.e. retrieving information about the database such as relations present in the database and the names and types of relation attributes. JDBC connects with the database as follows: 1.open a connection 2.create a “Statement” object 3.execute queries using the Statement object to send queries and fetch results 4.exception mechanism to handle errors
  • 62. Embedded SQL  Embedded SQL refers to embedding SQL queries in another language.  SQL can be embedded in various languages including C, Java and Cobol.  A language into which SQL queries are embedded is referred to as a host language, and the SQL structures permitted in the host language comprise embedded SQL.  The EXEC SQL statement is used to identify embedded SQL request to the preprocessor: EXEC SQL <embedded SQL statement> END_EXEC
  • 63. PHP  PHP is a server-side scripting language.  It was mainly developed for the web but can also be used as a general-purpose programming language.  PHP works well with MySQL and can be used in combination with HTML to create a webapp that connects to a database.
  • 64. PHP Working: 1.web browser sends HTTP requests and receives HTTP responses 2.PHP script (on the server-side) connects to DBMS and uses query results to produce its output 3.web server calls the PHP script and incorporates its output into the response 4.web browser renders the HTML document from the response
  • 65. PHP Executing SQL from PHP: 1.connect to server (mysql_connect) 2.select the database (mysql_select_db) 3.run query 4.retrieve row of results (mysql_fetch_array) 5.retrieve attributes (foreach)