SlideShare ist ein Scribd-Unternehmen logo
1 von 18
By: Rohan Byanjankar
Sainik Awasiya Mahavidyalaya, Sallaghari, Bhaktapur
CONCEPT OF RELATIONAL
DATABASE AND INTEGRITY
CONSTRAINTS
1
• Relational Database Model
• Introduction
• Data integrity (Entity integrity,…)
• Introduction to Integrity Constraints
• Domain Constraint
• Referential Integrity Constraint
Contents
2
• Relational Model was developed by E.F. Codd,
• Most popular database model in the world,
• The data are stored on relation (table), relation in Relational Database
is similar to table where column represents attributes, and
information are stored in rows.
Relational Database Model
ISBN Bname Price Author
000-124-456 The Old Man and
The Sea
Rs. 97 Ernest Hemingway
978-1-85326-067-4 Far from the
Madding Crowd
Rs. 200 Thomas Hardy
978-81-291-0818-0 One Night @ The
Call Center
Rs. 200 Chetan Bhagat
Attributes
Values/information
3
4
• The concept of Primary Key and Foreign Key helps to create logical
relationship between relations.
• Primary Key is a one of the best keys that is chosen by database
designer for the purpose of uniquely identifying all the entities of entity
set.
• A combination of a NOT NULL and UNIQUE. Ensures that a column (or
combination of two or more columns) have an unique identity which helps
to find a particular record in a table more easily and quickly.
• Foreign Key is actually the primary key of one table and serves as
attribute for another table.
• Ensures the referential integrity of the data in one table to match
values in another table
Contd…
5
Contd…
ISBN Bname Price Author
000-124-456 The Old Man and
The Sea
Rs. 97 Ernest Hemingway
978-1-85326-067-4 Far from the
Madding Crowd
Rs. 200 Thomas Hardy
978-81-291-0818-0 One Night @ The
Call Center
Rs. 200 Chetan Bhagat
ID Name Grade ISBN
0001 Sanjay Sharma BBA 978-81-291-0818-0
0002 Sushil Shrestha BSC 000-124-456
0030 Samikshaya Sharma BBA 978-1-85326-067-4
Foreign Key
6
• Integer : INT
• Number (Decimal) : FLOAT or REAL
• Currency : MONEY
• String (fixed) : CHAR
• String (Variable) : VARCHAR
• Date : DATETIME
Data Types and their Notation in SQL SERVER
7
• The fundamental set of rules,
• Implemented for the purpose of maintaining accuracy,
reliability, and consistency in data,
• Helps to avoid accidental deletion of data,
• Prevents the entry of invalid data in database,
Data integrity
8
Entity Integrity
- Generally applies on an attribute,
- Concerned with the presence of primary key in each relation(table),
- It advocates the following:
- Primary Key must be NOT NULL,
- Primary Key must be UNIQUE,
NOTE:
IF THERE IS NULL VALUE FOR A PRIMARY KEY, THEN IT
WILL BE UNATTAINABLE FOR US TO IDENTIFY ALL THE
TUPLES INDIVIDUALLY.
Types of Data Integrity
ISBN Bname Price Author
000-124-456 The Old Man and
The Sea
Rs. 97 Ernest Hemingway
978-1-85326-067-4 Far from the
Madding Crowd
Rs. 200 Thomas Hardy
978-81-291-0818-0 One Night @ The
Call Center
Rs. 200 Chetan Bhagat
PrimaryKey
IN SQL (Entity Integrity)
CREATE TABLE Library (
ISBN INT,
Bname VARCHAR (20),
Price MONEY,
Author VARCHAR (20),
CONSTRAINT pk_id PRIMARY KEY (ISBN));
10
•Domain Integrity
• Domain Constraint is one of the elementary form of integrity
constraint that helps to maintain accuracy and consistency,
• Helps to avoid duplication of data,
•Referential Integrity
• Enables to establish relationship between two relations through
the application of concept of PRIMARY KEY and FOREIGN
KEY.
Contd…
11
12
• Set of rules that helps to maintain correctness of data,
• Prevent from accidental deletion and insertion of data,
•Types of Integrity constraint
• Domain Constraint
• Referential Integrity Constraint
• Assertion
• Triggers
Integrity Constraint
13
• A domain is defined as the set of all unique values that can be
allowed for an attribute.
• For example, a domain of day-of-week is Sunday, Monday,
Tuesday ... Saturday.
• Domain Constraint is one of the elementary form of integrity
constraint that helps to maintain accuracy and consistency,
• Helps to avoid common errors such as date : 30th February, 2010…
• CHECK, UNIQUE, NOT NULL, PRIMARY KEY are the
examples of Domain Constraints
Domain Constraint
14
IN SQL (Domain Integrity)
CREATE TABLE Student (
ID INT PRIMARY KEY,
Sname VARCHAR (20) NOT NULL,
Grade VARCHAR (20),
Age INT CHECK(Age BETWEEN 19 AND 21),
Email_id VARCHAR (30) UNIQUE);
ID Sname Grade Age Email_id
0001 Sanjay Sharma BBA 20 sanjay120@gmail.com
0002 Sushil Shrestha BSC 21 Shth.susil@yahoo.com
0003 Samikshaya Sharma BBA 19 Sami.sharma@rediff.com
In Case:
INERT INTO Student VALUES (0004, ‘Nisha Thapa Magar’, ‘BBA’, 22,
‘sujan98@gmail.com’)
It will not be accepted as Age>21
CHECK
UNIQUE
Domain Integrity
PRIMARY KEY
NOT NULL
15
• Has sturdy link with entity integrity,
• The referential integrity relies on the entity integrity,
• Referential integrity is a property of data which, when satisfied,
requires every value of one attribute (column) of a relation (table)
to exist as a value of another attribute in a different (or the same)
relation (table).
• Referential Integrity is based on the concept of foreign key,
Referential Integrity Constraint
16
IN SQL (Entity Integrity)
CREATE TABLE Library (
ISBN INT,
Bname VARCHAR (20),
Price MONEY,
Author VARCHAR (20),
CONSTRAINT pk_id PRIMARY
KEY (ISBN));
IN SQL (Referential
Integrity)
CREATE TABLE Student (
ID INT PRIMARY KEY,
Sname VARCHAR (20),
Grade VARCHAR (20),
ISBN INT FOREIGN KEY
REFERENCES Library (ISBN));
ISBN INT
17
ISBN Bname Price Author
000-124-456 The Old Man and
The Sea
Rs. 97 Ernest Hemingway
978-1-85326-067-4 Far from the
Madding Crowd
Rs. 200 Thomas Hardy
978-81-291-0818-0 One Night @ The
Call Center
Rs. 200 Chetan Bhagat
ID Sname Grade ISBN
0001 Sanjay Sharma BBA 978-81-291-0818-0
0002 Sushil Shrestha BSC 000-124-456
0030 Samikshaya Sharma BBA 978-1-85326-067-4
Foreign Key
Library
Student
18
•Assertion
• General purpose CHECK that allows for the enforcement
of any condition over entire database
• Triggers
• Special type of stored procedure that automatically
gets executed in the DBMS in response to specific
change in database
Contd…

Weitere ähnliche Inhalte

Was ist angesagt?

Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagramsAjit Nayak
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra pptGirdharRatne
 
Requirement analysis and specification
Requirement analysis and specificationRequirement analysis and specification
Requirement analysis and specificationM.E. at GTU- PG School
 
1.4 data independence
1.4 data independence1.4 data independence
1.4 data independenceBHARATH KUMAR
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPTTrinath
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...Raj vardhan
 
Database abstraction
Database abstractionDatabase abstraction
Database abstractionRituBhargava7
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship modelJafar Nesargi
 
Data and functional modeling
Data and functional modelingData and functional modeling
Data and functional modelingSlideshare
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMSkoolkampus
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)tameemyousaf
 
Waterfall model ppt final
Waterfall model ppt  finalWaterfall model ppt  final
Waterfall model ppt finalshiva krishna
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML DiagramsManish Kumar
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedurepragya ratan
 
Codd's rules
Codd's rulesCodd's rules
Codd's rulesMohd Arif
 

Was ist angesagt? (20)

Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 
Requirement analysis and specification
Requirement analysis and specificationRequirement analysis and specification
Requirement analysis and specification
 
1.4 data independence
1.4 data independence1.4 data independence
1.4 data independence
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
DBMS and its Models
DBMS and its ModelsDBMS and its Models
DBMS and its Models
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
Database abstraction
Database abstractionDatabase abstraction
Database abstraction
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship model
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Data and functional modeling
Data and functional modelingData and functional modeling
Data and functional modeling
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Waterfall model ppt final
Waterfall model ppt  finalWaterfall model ppt  final
Waterfall model ppt final
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 
Codd's rules
Codd's rulesCodd's rules
Codd's rules
 

Andere mochten auch

Andere mochten auch (16)

Sql
SqlSql
Sql
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Data integrity
Data integrityData integrity
Data integrity
 
3 summary
3 summary3 summary
3 summary
 
Relational keys
Relational keysRelational keys
Relational keys
 
Basic example using database component
Basic example using database componentBasic example using database component
Basic example using database component
 
Chap08
Chap08Chap08
Chap08
 
Digital Menu Boards Guide 2014
Digital Menu Boards Guide 2014 Digital Menu Boards Guide 2014
Digital Menu Boards Guide 2014
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 
Key database terms
Key database termsKey database terms
Key database terms
 
integrity constraints
integrity constraintsintegrity constraints
integrity constraints
 
How to sharpen skis
How to sharpen skisHow to sharpen skis
How to sharpen skis
 
Whitmore Sonja 3.3
Whitmore Sonja 3.3Whitmore Sonja 3.3
Whitmore Sonja 3.3
 
zulkernine_zanonudin
zulkernine_zanonudinzulkernine_zanonudin
zulkernine_zanonudin
 
KEI_Book_Sample
KEI_Book_SampleKEI_Book_Sample
KEI_Book_Sample
 
Análisis y perspectivas del cluster canalero
Análisis y perspectivas del cluster canaleroAnálisis y perspectivas del cluster canalero
Análisis y perspectivas del cluster canalero
 

Ähnlich wie Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN PRIMARY KEY AND UNIQUE AND NOT NULL].

Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAGeek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAIDERA Software
 
Structured Query Language (SQL) _ Edu4Sure Training.pptx
Structured Query Language (SQL) _ Edu4Sure Training.pptxStructured Query Language (SQL) _ Edu4Sure Training.pptx
Structured Query Language (SQL) _ Edu4Sure Training.pptxEdu4Sure
 
NoSQL, SQL, NewSQL - methods of structuring data.
NoSQL, SQL, NewSQL - methods of structuring data.NoSQL, SQL, NewSQL - methods of structuring data.
NoSQL, SQL, NewSQL - methods of structuring data.Tony Rogerson
 
Relational database management system
Relational database management systemRelational database management system
Relational database management systemPraveen Soni
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal waghharshalkwagh999
 
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdf
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdfComplete SQL Tutorial In Hindi By Rishabh Mishra.pdf
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdfssuserb5bb0e
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdfGOWTHAMR721887
 
Csis110 trzos-c1 ms access
Csis110 trzos-c1 ms accessCsis110 trzos-c1 ms access
Csis110 trzos-c1 ms accesstomtrzos
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptxMohit89650
 
5. relational structure
5. relational structure5. relational structure
5. relational structurekhoahuy82
 

Ähnlich wie Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN PRIMARY KEY AND UNIQUE AND NOT NULL]. (14)

Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAGeek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
Structured Query Language (SQL) _ Edu4Sure Training.pptx
Structured Query Language (SQL) _ Edu4Sure Training.pptxStructured Query Language (SQL) _ Edu4Sure Training.pptx
Structured Query Language (SQL) _ Edu4Sure Training.pptx
 
NoSQL, SQL, NewSQL - methods of structuring data.
NoSQL, SQL, NewSQL - methods of structuring data.NoSQL, SQL, NewSQL - methods of structuring data.
NoSQL, SQL, NewSQL - methods of structuring data.
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
 
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdf
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdfComplete SQL Tutorial In Hindi By Rishabh Mishra.pdf
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdf
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf
 
Csis110 trzos-c1 ms access
Csis110 trzos-c1 ms accessCsis110 trzos-c1 ms access
Csis110 trzos-c1 ms access
 
Exalead managing terrabytes
Exalead   managing terrabytesExalead   managing terrabytes
Exalead managing terrabytes
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptx
 
5. relational structure
5. relational structure5. relational structure
5. relational structure
 

Mehr von Rohan Byanjankar

12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data Analysis12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data AnalysisRohan Byanjankar
 
Risk Associated with Derivative Markets
Risk Associated with Derivative MarketsRisk Associated with Derivative Markets
Risk Associated with Derivative MarketsRohan Byanjankar
 
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...Rohan Byanjankar
 
Multiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of MultiplierMultiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of MultiplierRohan Byanjankar
 
Origin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign CountryOrigin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign CountryRohan Byanjankar
 
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...Rohan Byanjankar
 
Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...Rohan Byanjankar
 
A Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctorA Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctorRohan Byanjankar
 
Siddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, NepalSiddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, NepalRohan Byanjankar
 
Trade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, NepalTrade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, NepalRohan Byanjankar
 
Sociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social InstitutionSociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social InstitutionRohan Byanjankar
 
Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...Rohan Byanjankar
 
Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...Rohan Byanjankar
 
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...Rohan Byanjankar
 
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...Rohan Byanjankar
 
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...Rohan Byanjankar
 
Difference between selling concept and marketing concept
Difference between selling concept and marketing conceptDifference between selling concept and marketing concept
Difference between selling concept and marketing conceptRohan Byanjankar
 

Mehr von Rohan Byanjankar (19)

12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data Analysis12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data Analysis
 
Concept of annuity
Concept of annuityConcept of annuity
Concept of annuity
 
Risk Associated with Derivative Markets
Risk Associated with Derivative MarketsRisk Associated with Derivative Markets
Risk Associated with Derivative Markets
 
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
 
Multiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of MultiplierMultiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of Multiplier
 
Origin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign CountryOrigin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign Country
 
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
 
Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...
 
A Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctorA Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctor
 
Siddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, NepalSiddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, Nepal
 
Trade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, NepalTrade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, Nepal
 
Introduction to HASERA
Introduction to HASERAIntroduction to HASERA
Introduction to HASERA
 
Sociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social InstitutionSociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social Institution
 
Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...
 
Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...
 
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
 
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
 
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
 
Difference between selling concept and marketing concept
Difference between selling concept and marketing conceptDifference between selling concept and marketing concept
Difference between selling concept and marketing concept
 

Kürzlich hochgeladen

Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 

Kürzlich hochgeladen (20)

Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 

Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN PRIMARY KEY AND UNIQUE AND NOT NULL].

  • 1. By: Rohan Byanjankar Sainik Awasiya Mahavidyalaya, Sallaghari, Bhaktapur CONCEPT OF RELATIONAL DATABASE AND INTEGRITY CONSTRAINTS 1
  • 2. • Relational Database Model • Introduction • Data integrity (Entity integrity,…) • Introduction to Integrity Constraints • Domain Constraint • Referential Integrity Constraint Contents 2
  • 3. • Relational Model was developed by E.F. Codd, • Most popular database model in the world, • The data are stored on relation (table), relation in Relational Database is similar to table where column represents attributes, and information are stored in rows. Relational Database Model ISBN Bname Price Author 000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway 978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy 978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat Attributes Values/information 3
  • 4. 4 • The concept of Primary Key and Foreign Key helps to create logical relationship between relations. • Primary Key is a one of the best keys that is chosen by database designer for the purpose of uniquely identifying all the entities of entity set. • A combination of a NOT NULL and UNIQUE. Ensures that a column (or combination of two or more columns) have an unique identity which helps to find a particular record in a table more easily and quickly. • Foreign Key is actually the primary key of one table and serves as attribute for another table. • Ensures the referential integrity of the data in one table to match values in another table Contd…
  • 5. 5 Contd… ISBN Bname Price Author 000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway 978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy 978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat ID Name Grade ISBN 0001 Sanjay Sharma BBA 978-81-291-0818-0 0002 Sushil Shrestha BSC 000-124-456 0030 Samikshaya Sharma BBA 978-1-85326-067-4 Foreign Key
  • 6. 6 • Integer : INT • Number (Decimal) : FLOAT or REAL • Currency : MONEY • String (fixed) : CHAR • String (Variable) : VARCHAR • Date : DATETIME Data Types and their Notation in SQL SERVER
  • 7. 7 • The fundamental set of rules, • Implemented for the purpose of maintaining accuracy, reliability, and consistency in data, • Helps to avoid accidental deletion of data, • Prevents the entry of invalid data in database, Data integrity
  • 8. 8 Entity Integrity - Generally applies on an attribute, - Concerned with the presence of primary key in each relation(table), - It advocates the following: - Primary Key must be NOT NULL, - Primary Key must be UNIQUE, NOTE: IF THERE IS NULL VALUE FOR A PRIMARY KEY, THEN IT WILL BE UNATTAINABLE FOR US TO IDENTIFY ALL THE TUPLES INDIVIDUALLY. Types of Data Integrity
  • 9. ISBN Bname Price Author 000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway 978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy 978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat PrimaryKey IN SQL (Entity Integrity) CREATE TABLE Library ( ISBN INT, Bname VARCHAR (20), Price MONEY, Author VARCHAR (20), CONSTRAINT pk_id PRIMARY KEY (ISBN));
  • 10. 10 •Domain Integrity • Domain Constraint is one of the elementary form of integrity constraint that helps to maintain accuracy and consistency, • Helps to avoid duplication of data, •Referential Integrity • Enables to establish relationship between two relations through the application of concept of PRIMARY KEY and FOREIGN KEY. Contd…
  • 11. 11
  • 12. 12 • Set of rules that helps to maintain correctness of data, • Prevent from accidental deletion and insertion of data, •Types of Integrity constraint • Domain Constraint • Referential Integrity Constraint • Assertion • Triggers Integrity Constraint
  • 13. 13 • A domain is defined as the set of all unique values that can be allowed for an attribute. • For example, a domain of day-of-week is Sunday, Monday, Tuesday ... Saturday. • Domain Constraint is one of the elementary form of integrity constraint that helps to maintain accuracy and consistency, • Helps to avoid common errors such as date : 30th February, 2010… • CHECK, UNIQUE, NOT NULL, PRIMARY KEY are the examples of Domain Constraints Domain Constraint
  • 14. 14 IN SQL (Domain Integrity) CREATE TABLE Student ( ID INT PRIMARY KEY, Sname VARCHAR (20) NOT NULL, Grade VARCHAR (20), Age INT CHECK(Age BETWEEN 19 AND 21), Email_id VARCHAR (30) UNIQUE); ID Sname Grade Age Email_id 0001 Sanjay Sharma BBA 20 sanjay120@gmail.com 0002 Sushil Shrestha BSC 21 Shth.susil@yahoo.com 0003 Samikshaya Sharma BBA 19 Sami.sharma@rediff.com In Case: INERT INTO Student VALUES (0004, ‘Nisha Thapa Magar’, ‘BBA’, 22, ‘sujan98@gmail.com’) It will not be accepted as Age>21 CHECK UNIQUE Domain Integrity PRIMARY KEY NOT NULL
  • 15. 15 • Has sturdy link with entity integrity, • The referential integrity relies on the entity integrity, • Referential integrity is a property of data which, when satisfied, requires every value of one attribute (column) of a relation (table) to exist as a value of another attribute in a different (or the same) relation (table). • Referential Integrity is based on the concept of foreign key, Referential Integrity Constraint
  • 16. 16 IN SQL (Entity Integrity) CREATE TABLE Library ( ISBN INT, Bname VARCHAR (20), Price MONEY, Author VARCHAR (20), CONSTRAINT pk_id PRIMARY KEY (ISBN)); IN SQL (Referential Integrity) CREATE TABLE Student ( ID INT PRIMARY KEY, Sname VARCHAR (20), Grade VARCHAR (20), ISBN INT FOREIGN KEY REFERENCES Library (ISBN)); ISBN INT
  • 17. 17 ISBN Bname Price Author 000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway 978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy 978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat ID Sname Grade ISBN 0001 Sanjay Sharma BBA 978-81-291-0818-0 0002 Sushil Shrestha BSC 000-124-456 0030 Samikshaya Sharma BBA 978-1-85326-067-4 Foreign Key Library Student
  • 18. 18 •Assertion • General purpose CHECK that allows for the enforcement of any condition over entire database • Triggers • Special type of stored procedure that automatically gets executed in the DBMS in response to specific change in database Contd…