SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
DATABASE
MANAGEMENT SYSTEMS
Unit / Topic: II /I
Relational Model
• Primary data model for commercial data processing
applications.
• Consists of relational databases.
• Advantages:
Simplicity
Easier for accessing data
Structure of Relational Databases
• Relational database  collection of tables with unique
names
• Tables  called as relations
• Rows of the table  records or tuples
• Columns of the table  attributes or fields
Contd..
• Set of permitted values of the attributes  domain
values
• Null value  special value that signifies that the
value is unknown or does not exist
Example
Database Schema and Instance
• Database schema:
Logical design or overall design of the database
Does not change frequently
Eg: university (instructor, student)
• Database instance:
Snapshot of the data in the database at a given
instant in time.
Changes frequently
Relation Schema and Instance
Relation schema:
• Consists of a list of attributes and their corresponding
domains.
• Similar to a variable in programming language.
• Does not change frequently
• Eg: instructor = (ID, name, dept_name, salary)
Relation instance:
• Set of domain values in a relation at a particular point of
time or current values
• Similar to value of a variable in programming language
• Changes frequently
Example
Schema
Instance
Keys
Types of keys:
Super key
Candidate key
Primary key
Foreign key
Primary Key
• Main reference key of the table
• One of the candidate keys that is most appropriate
to uniquely identify a record in a table.
Candidate Key
• Subset of super key
• Minimal super key
• Single field or least combination of fields that
uniquely identifies each record in the table
Super Key
• A super key is a set of attributes of any combination
that uniquely identifies a record within a table.
• Given table:
STUDENT{StudentId, firstName, lastName,
courseId}
• Possible superkeys are:
o {StudentId}
o {StudentId, firstName}
o {firstName, lastName}
o (StudentId, firstName, lastName, courseId}
Foreign key
• Used to relate two tables
• Primary key of one table (parent table) acts as a key
for another table (child table) in order to provide
relationship between these two tables
• That non-primary key attribute is said to be the
foreign key for the parent table
• Child table is called as the referencing relation and
the parent table is called as the referenced relation
Example
Referential Integrity Constraints
• Set of constraints applied to foreign key which
prevents entering a row in child table (where you
have foreign key) for which you don't have any
corresponding row in parent table.
• Referential Integrity prevents your table from
having incorrect or incomplete relationship.
Schema Diagrams
• Pictorial representation of database schemas
• A database schema along with primary key and
foreign key dependencies can be depicted by
schema diagrams
Schema Diagram for the University Database
Formal Query Languages
Relational Algebra
Introduction
• Query  retrieval of information
• Query language  language that is used for
information retrieval
• Formal query languages  based upon which SQL
is developed
• Types:
Relational Algebra
Relational Calculus
Tuple Relational Calculus
Domain Relational Calculus
Relational Algebra
• Procedural query language
• Consists of a set of operations that take one or two
relations as input and produce a new single relation as
their output
Fundamental Operations
• Select
• Project
• Union
• Set difference
• Cartesian product
• Rename
Note: select, project, rename – called as ‘unary’
operators and the remaining are ‘binary’ operators
Select Operation
• The select operation display tuples that satisfy a
given predicate (condition).
• We use the lowercase Greek letter sigma to
denote selection.
• It produces a “horizontal” subset.
• Syntax: sC(R)
– where C is a selection condition(=, <, >, =<, >=,
<>)
– and R is the relation over which the selection
takes place
Example of Select
Student
Find all students whose id is above 300.
Query: s sid > 300(Student)
Resulting Relation:
sid name addr
123 Fred 3 Oxford
345 John 6 Hope Rd.
567 Ann 5 Garden
sid name addr
345 John 6 Hope Rd.
567 Ann 5 Garden
Project Operation
• The project operation display attributes that
satisfy a given predicate (condition).
• We use the lowercase Greek letter pi to
denote selection.
• It produces a “vertical” subset.
• Eliminates duplicated values.
• Syntax: ПA(R)
– where A is a set of attributes of R
– and R is the relation over which the project
takes place
Example of Project
Enrollment
Display all sid values
Query: Пsid(Enrollment)
sid name addr
123 Fred 3 Oxford
345 John 6 Hope Rd.
567 Ann 5 Garden
sid
123
345
567
SELECTION & PROJECTION Example
Id Name Address Hobby
1123 John 123 Main stamps
1123 John 123 Main coins
5556 Mary 7 Lake Dr hiking
9876 Bart 5 Pine St stamps
Id Name Address Hobby
1123 John 123 Main stamps
9876 Bart 5 Pine St stamps
σ Hobby=‘stamps’(Person)
Person
∏Name, Hobby(Person)
Name Hobby
John stamps
John coins
Mary Hiking
Bart stamps
28
Examples
•  Id>3000 OR Hobby=‘hiking’ (Person)
•  Id>3000 AND Id <3999 (Person)
•  NOT(Hobby=‘hiking’) (Person)
•  Hobby‘hiking’ (Person)
•  Id (Person)
•  Hobby (Person)
Relational Algebra Expressions
Union Operation
• Creates a relation that contains all the values in both
the relations.
• Two relations are union compatible if:
– Both have same number of columns
– Names of attributes are the same in both
• Represented using the symbol ‘∪’.
• Eliminate duplicates
• Syntax: S1 ∪ S2
– where S1, S2 are separate relations
Example
The Set-Difference Operation
• Allows us to find tuples that are in one relation but
are not in another.
• Denoted by the symbol ‘−’.
• Syntax: S1 – S2
• where S1, S2 are separate relations
Example
Example
SUMMARY
INTRODUCTION TO RELATIONAL MODEL
• Structure of Relational Databases
o Tables
o Records or tuples
o Attributes or fields
o Domain values
o Null values
• Difference b/w database schema and database instance
• Difference b/w relation schema and relation instance
• Keys
o Super key
o Candidate key
o Primary key
o Foreign key
• Referential integrity constraint
• Fundamental database operations

Weitere ähnliche Inhalte

Ähnlich wie 19IS305_U2_LP4_LM4-22-23.pdf

316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasex316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasexabhaysonone0
 
Data Base Management System.pdf
Data Base Management System.pdfData Base Management System.pdf
Data Base Management System.pdfTENZING LHADON
 
Relational data model
Relational data modelRelational data model
Relational data modelSURBHI SAROHA
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptxMohit89650
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdfCynthiaAdzornu
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization Hafiz faiz
 
DBMS-Quick Reference
DBMS-Quick ReferenceDBMS-Quick Reference
DBMS-Quick ReferenceShrija Madhu
 
Databases for beginners.pdf
Databases for beginners.pdfDatabases for beginners.pdf
Databases for beginners.pdffikadumola
 
Relational_Algebra Database management system
Relational_Algebra Database management systemRelational_Algebra Database management system
Relational_Algebra Database management systemSupportcse5
 
relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptxNirajG3
 

Ähnlich wie 19IS305_U2_LP4_LM4-22-23.pdf (20)

316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasex316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasex
 
Data Base Management System.pdf
Data Base Management System.pdfData Base Management System.pdf
Data Base Management System.pdf
 
Relational data model
Relational data modelRelational data model
Relational data model
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptx
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
RDBMS Model
RDBMS ModelRDBMS Model
RDBMS Model
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization
 
lecture5.ppt
lecture5.pptlecture5.ppt
lecture5.ppt
 
DBMS-Quick Reference
DBMS-Quick ReferenceDBMS-Quick Reference
DBMS-Quick Reference
 
Databases for beginners.pdf
Databases for beginners.pdfDatabases for beginners.pdf
Databases for beginners.pdf
 
Relational_Algebra Database management system
Relational_Algebra Database management systemRelational_Algebra Database management system
Relational_Algebra Database management system
 
Database intro
Database introDatabase intro
Database intro
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptx
 
My sql
My sqlMy sql
My sql
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql commands
Sql commandsSql commands
Sql commands
 

Mehr von GOWTHAMR721887

19IS402_LP3.1_LM_22-23.pdf
19IS402_LP3.1_LM_22-23.pdf19IS402_LP3.1_LM_22-23.pdf
19IS402_LP3.1_LM_22-23.pdfGOWTHAMR721887
 
19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdfGOWTHAMR721887
 
22PH102_ISE_U3_LP1_-_Notes.pdf
22PH102_ISE_U3_LP1_-_Notes.pdf22PH102_ISE_U3_LP1_-_Notes.pdf
22PH102_ISE_U3_LP1_-_Notes.pdfGOWTHAMR721887
 
22PH102_ISE_U2_LP1_-_Notes.pdf
22PH102_ISE_U2_LP1_-_Notes.pdf22PH102_ISE_U2_LP1_-_Notes.pdf
22PH102_ISE_U2_LP1_-_Notes.pdfGOWTHAMR721887
 
19IS303_22-23_LM11.pdf
19IS303_22-23_LM11.pdf19IS303_22-23_LM11.pdf
19IS303_22-23_LM11.pdfGOWTHAMR721887
 
19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdfGOWTHAMR721887
 
An Internet of Things Based Smart Waste.pptx
An Internet of Things Based Smart Waste.pptxAn Internet of Things Based Smart Waste.pptx
An Internet of Things Based Smart Waste.pptxGOWTHAMR721887
 

Mehr von GOWTHAMR721887 (7)

19IS402_LP3.1_LM_22-23.pdf
19IS402_LP3.1_LM_22-23.pdf19IS402_LP3.1_LM_22-23.pdf
19IS402_LP3.1_LM_22-23.pdf
 
19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf
 
22PH102_ISE_U3_LP1_-_Notes.pdf
22PH102_ISE_U3_LP1_-_Notes.pdf22PH102_ISE_U3_LP1_-_Notes.pdf
22PH102_ISE_U3_LP1_-_Notes.pdf
 
22PH102_ISE_U2_LP1_-_Notes.pdf
22PH102_ISE_U2_LP1_-_Notes.pdf22PH102_ISE_U2_LP1_-_Notes.pdf
22PH102_ISE_U2_LP1_-_Notes.pdf
 
19IS303_22-23_LM11.pdf
19IS303_22-23_LM11.pdf19IS303_22-23_LM11.pdf
19IS303_22-23_LM11.pdf
 
19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf
 
An Internet of Things Based Smart Waste.pptx
An Internet of Things Based Smart Waste.pptxAn Internet of Things Based Smart Waste.pptx
An Internet of Things Based Smart Waste.pptx
 

Kürzlich hochgeladen

High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 

19IS305_U2_LP4_LM4-22-23.pdf

  • 2. Relational Model • Primary data model for commercial data processing applications. • Consists of relational databases. • Advantages: Simplicity Easier for accessing data
  • 3. Structure of Relational Databases • Relational database  collection of tables with unique names • Tables  called as relations • Rows of the table  records or tuples • Columns of the table  attributes or fields
  • 4. Contd.. • Set of permitted values of the attributes  domain values • Null value  special value that signifies that the value is unknown or does not exist
  • 6. Database Schema and Instance • Database schema: Logical design or overall design of the database Does not change frequently Eg: university (instructor, student) • Database instance: Snapshot of the data in the database at a given instant in time. Changes frequently
  • 7. Relation Schema and Instance Relation schema: • Consists of a list of attributes and their corresponding domains. • Similar to a variable in programming language. • Does not change frequently • Eg: instructor = (ID, name, dept_name, salary) Relation instance: • Set of domain values in a relation at a particular point of time or current values • Similar to value of a variable in programming language • Changes frequently
  • 9. Keys Types of keys: Super key Candidate key Primary key Foreign key
  • 10. Primary Key • Main reference key of the table • One of the candidate keys that is most appropriate to uniquely identify a record in a table.
  • 11. Candidate Key • Subset of super key • Minimal super key • Single field or least combination of fields that uniquely identifies each record in the table
  • 12. Super Key • A super key is a set of attributes of any combination that uniquely identifies a record within a table. • Given table: STUDENT{StudentId, firstName, lastName, courseId} • Possible superkeys are: o {StudentId} o {StudentId, firstName} o {firstName, lastName} o (StudentId, firstName, lastName, courseId}
  • 13. Foreign key • Used to relate two tables • Primary key of one table (parent table) acts as a key for another table (child table) in order to provide relationship between these two tables • That non-primary key attribute is said to be the foreign key for the parent table • Child table is called as the referencing relation and the parent table is called as the referenced relation
  • 15. Referential Integrity Constraints • Set of constraints applied to foreign key which prevents entering a row in child table (where you have foreign key) for which you don't have any corresponding row in parent table. • Referential Integrity prevents your table from having incorrect or incomplete relationship.
  • 16. Schema Diagrams • Pictorial representation of database schemas • A database schema along with primary key and foreign key dependencies can be depicted by schema diagrams
  • 17. Schema Diagram for the University Database
  • 19. Introduction • Query  retrieval of information • Query language  language that is used for information retrieval • Formal query languages  based upon which SQL is developed • Types: Relational Algebra Relational Calculus Tuple Relational Calculus Domain Relational Calculus
  • 20. Relational Algebra • Procedural query language • Consists of a set of operations that take one or two relations as input and produce a new single relation as their output
  • 21. Fundamental Operations • Select • Project • Union • Set difference • Cartesian product • Rename Note: select, project, rename – called as ‘unary’ operators and the remaining are ‘binary’ operators
  • 22. Select Operation • The select operation display tuples that satisfy a given predicate (condition). • We use the lowercase Greek letter sigma to denote selection. • It produces a “horizontal” subset. • Syntax: sC(R) – where C is a selection condition(=, <, >, =<, >=, <>) – and R is the relation over which the selection takes place
  • 23. Example of Select Student Find all students whose id is above 300. Query: s sid > 300(Student) Resulting Relation: sid name addr 123 Fred 3 Oxford 345 John 6 Hope Rd. 567 Ann 5 Garden sid name addr 345 John 6 Hope Rd. 567 Ann 5 Garden
  • 24. Project Operation • The project operation display attributes that satisfy a given predicate (condition). • We use the lowercase Greek letter pi to denote selection. • It produces a “vertical” subset. • Eliminates duplicated values. • Syntax: ПA(R) – where A is a set of attributes of R – and R is the relation over which the project takes place
  • 25. Example of Project Enrollment Display all sid values Query: Пsid(Enrollment) sid name addr 123 Fred 3 Oxford 345 John 6 Hope Rd. 567 Ann 5 Garden sid 123 345 567
  • 26.
  • 27. SELECTION & PROJECTION Example Id Name Address Hobby 1123 John 123 Main stamps 1123 John 123 Main coins 5556 Mary 7 Lake Dr hiking 9876 Bart 5 Pine St stamps Id Name Address Hobby 1123 John 123 Main stamps 9876 Bart 5 Pine St stamps σ Hobby=‘stamps’(Person) Person ∏Name, Hobby(Person) Name Hobby John stamps John coins Mary Hiking Bart stamps
  • 28. 28 Examples •  Id>3000 OR Hobby=‘hiking’ (Person) •  Id>3000 AND Id <3999 (Person) •  NOT(Hobby=‘hiking’) (Person) •  Hobby‘hiking’ (Person) •  Id (Person) •  Hobby (Person)
  • 30. Union Operation • Creates a relation that contains all the values in both the relations. • Two relations are union compatible if: – Both have same number of columns – Names of attributes are the same in both • Represented using the symbol ‘∪’. • Eliminate duplicates • Syntax: S1 ∪ S2 – where S1, S2 are separate relations
  • 32. The Set-Difference Operation • Allows us to find tuples that are in one relation but are not in another. • Denoted by the symbol ‘−’. • Syntax: S1 – S2 • where S1, S2 are separate relations
  • 35. SUMMARY INTRODUCTION TO RELATIONAL MODEL • Structure of Relational Databases o Tables o Records or tuples o Attributes or fields o Domain values o Null values • Difference b/w database schema and database instance • Difference b/w relation schema and relation instance • Keys o Super key o Candidate key o Primary key o Foreign key • Referential integrity constraint • Fundamental database operations