SlideShare a Scribd company logo
1 of 8
Download to read offline
Relational Database
• Relations can be represented as two-dimensional data tables with rows and
columns.
• The rows of a relation are called tuples.
• The columns of a relation are called attributes.
• The attributes draw values from a domain (a legal pool of values).
• The number of tuples in a relation is called its cardinality while the number of
attributes in a relation is called its degree.
• A relation also consists of a schema and an instance.
• Schema defines the structure of a relation which consists of a fixed set of
attribute-domain pairs.
• An instance of a relation is a time-varying set of tuples where each tuple consists
of attribute-value pairs.
Constraints: Set of rules for the database is known as constraints
• Domain Constraints:
Restrictions on the set of values of the attribute can take can be specified.
• Key Constraints:
A relation is defined to be set of tuples, since a set does not contain duplicates, no
two tuples can be identical.
• Entity Integrity Constraints:
Are the set of rules called by the application and these are applicable on all
instances of the relations
• Referential Integrity Constraint:
This is a special type of integrity constraint that relates two relations and
maintains consistency across the relations.
Data Integrity Data Integrity falls into the following categories:
• Entity integrity
Entity integrity ensures that each row can be uniquely identified by an attribute
called the Primary key. The Primary key cannot have a NULL value.
• Domain integrity
Domain integrity refers to the range of valid entries for a given column. It ensures
that there are only valid entries in the column.
• Referential integrity
Referential integrity ensures that for every value of a Foreign key, there is a
matching value of the Primary key.
Relational Algebra
• Relational Algebra is a procedural language used for manipulating relations.
• The relational model gives the structure for relations so that data can be stored in
that format but relational algebra enables us to retrieve information from relations.
The operators of Relational Algebra are:
• Select:
This is a unary operator that select a subset of tuples of the relation, which satisfy
selection condition. This can be represented by
• Project:
This is also a unary operator, that chooses subset of attributes or columns of a
relation and restricts all the tuples of a relation to those attributes. This is
represented by
The operators of Relational Algebra are:
• Cartesian Product:
This is a binary operator that combines information across two relations.
Cartesian product of two relations
R = (A1, A2, A3, A4, ….) and S = (B1, B2, B3,…) can be represented as:
Q = R X S = (A1, A2, A3, ….. B1, B2, B3,…).
• Join:
This is also a binary operator which is widely used and this operator concatenates
only tuples that satisfy certain conditions.
This is represented by:
Union, Intersection and Difference:
• To have union relations must have same number of attributes and corresponding
attributes must have same domain.
• Also since the result of each of these operators has to be a relation, duplicates are
removed.
Database Planning
• The database design should be adequate for serving different applications.
• Improper database planning will result in loss of data interrelationship,
repeatability of data, loss of data share, loss of control on data etc.
Basically one can classify the needs into three categories as
below:
• Operational database, which contains data assisting day to day activities of the
organization. Ex.: sales, product stock, etc.
• Control database, which contains data assisting needs of middle management to
monitor and control business activities by effective and efficient management of
men, machines and money. For example: monthly performance summaries, sales
statements etc.
• Strategic planning database, which contains data required for top management for
taking long-term decisions like economic policies of government, similar type of
organisation etc.
Steps in Database Planning
• Before designing the database certain decision has to be taken regarding approach
and type of database.
• An organisation may go for single large global database or separate databases
serving different groups of applications.
Single global database
• Results from total systems approach where requirements of entire organisation
and business functions are inter-related.
• This results in minimum redundancy and maximum of data.
• This also allows full control over the data design and access.
• This approach results in more complex database having large number of data
types and relationships and requires considerable time and effort in design and
implementation.
Multiple database approach
• Reduces time and effort required for design and lesser risk in database
management.
• However this approach may lead to problems in sharing of data and inter-
operability.
A database can be designed using top-down and bottom-up
approach. Top-down approach
• Starts with enterprise level model, preparing data model for entire application
domain.
• This approach does not consider specific details of processing.
• The ER model is prepared identifying the main entities and relationships.
• With this approach, there is a possibility of not accounting all user requirements,
missing certain entities or relationships.
Bottom-up approach
• Begins with individual user requirements.
• Data model for each requirement is prepared understating the inputs, outputs and
process.
• These individual models then merged into a single conceptual schema.
• The main disadvantage of this approach is it fails to take into account future
requirements.
After deciding on the approach, planning is carried out for
database design. The important points to be kept in mind
while planning are as listed below:
• Decide on the business steps, which will make use of database.
• Establish database administrative function.
• Perform business system analysis
• Build information model
• Developing data distribution plan.
• Develop Implementation Plan.
• Review.
Database Design
Some guidelines to be followed while designing the database:
• A database design should be unambiguous and easy to understand.
• It should avoid / reduce the redundancy.
• Unrelated data should be in separate table so that updating the data will be easy.
• Design should have no inconsistencies.
• An entity should have attributes, which are generally present for all its instances.
Minimise null values to the attributes in the design.
• Define constraints so that correctness of data will be ensured.
• Design should facilitate information addition in future.
• Maintenance should be easy.
• Some of these can be translated into design principles for good relations.
From the point of view of user, important criteria for designing
are:
• Meaningful grouping of attributes
• No redundancy
• No inapplicable attributes
• Uniformity in naming and definitions of the data items.
Conversion of ER Diagram to Relations
• The ER model represents the conceptual entities and their interrelationships at a
logical level.
• Using some simple rules one can convert ER model to relational database.
• The relational database obtained in this approach will avoid redundancies and
update anomalies.
• This is possible only if ER diagram is drawn correctly.
The rules, which are to be followed to derive the relational
model from the ER diagram, are:
• Define a table for each strong entity where the table has one column for each
simple attribute. The key of the table will be key of the entity itself.
• Define a table for each weak entity. It will contain the primary key of the strong
entity on which it depends, and it will also include attributes of the weak entity.
• Define a table for each relationship where the table consists of the primary keys of
the participating entity sets and the attributes of the relationship itself.
• For one to one relationships, it is not necessary to define a separate table.
• Try to avoid defining a separate table for many to one binary relationship.
• Consider the example of student and course.
• Here the relationship is many to many.
• From the above rules, we can define three tables for this situation namely student
entity, course entity and study relationship.
STUDENT
SUBJECT
STUDY

More Related Content

What's hot (18)

Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01
 
Data base management system
Data base management systemData base management system
Data base management system
 
Assignment on dbms
Assignment on dbmsAssignment on dbms
Assignment on dbms
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Database system architecture
Database system architectureDatabase system architecture
Database system architecture
 
Chapter1
Chapter1Chapter1
Chapter1
 
DBMS - RAID
DBMS - RAIDDBMS - RAID
DBMS - RAID
 
Database management system by Gursharan singh
Database management system by Gursharan singhDatabase management system by Gursharan singh
Database management system by Gursharan singh
 
Data abstraction in DBMS
Data abstraction in DBMSData abstraction in DBMS
Data abstraction in DBMS
 
Dbms Networks
Dbms NetworksDbms Networks
Dbms Networks
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
 
Dbms notesization 2014
Dbms notesization 2014Dbms notesization 2014
Dbms notesization 2014
 
Relational database oracle
Relational database  oracleRelational database  oracle
Relational database oracle
 
Dbms
DbmsDbms
Dbms
 
Slide 4 dbms users
Slide 4 dbms usersSlide 4 dbms users
Slide 4 dbms users
 
Lesson 1 data processing
Lesson 1   data processing Lesson 1   data processing
Lesson 1 data processing
 
Architec design introduction
Architec design introductionArchitec design introduction
Architec design introduction
 
Discussion unit 3 2203
Discussion unit 3 2203Discussion unit 3 2203
Discussion unit 3 2203
 

Similar to Relational database (Unit 2)

Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxMaryJoseph79
 
DBMS data modeling.pptx
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptxMrwafaAbbas
 
Week 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptxWeek 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptxRiannel Tecson
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemSelshaCs
 
Specifying data requirments
Specifying data requirmentsSpecifying data requirments
Specifying data requirmentsImran60577
 
Lecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptxLecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptxArifKamal36
 
SQL Tutorial - Basics of Structured Query Language Day 1.pdf
SQL Tutorial - Basics of Structured Query Language Day 1.pdfSQL Tutorial - Basics of Structured Query Language Day 1.pdf
SQL Tutorial - Basics of Structured Query Language Day 1.pdfRiturajDas28
 
Data warehouse 17 dimensional data model
Data warehouse 17 dimensional data modelData warehouse 17 dimensional data model
Data warehouse 17 dimensional data modelVaibhav Khanna
 
ch2-slide Data Models.pptx
ch2-slide Data Models.pptxch2-slide Data Models.pptx
ch2-slide Data Models.pptxTamiratDejene1
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelKunal Anand
 
Module 1 - Chapter 2.pptx
Module 1 - Chapter 2.pptxModule 1 - Chapter 2.pptx
Module 1 - Chapter 2.pptxSoniaDevi15
 
Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxNurulIzrin
 

Similar to Relational database (Unit 2) (20)

Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptx
 
DBMS data modeling.pptx
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptx
 
DATA MODELS.pptx
DATA MODELS.pptxDATA MODELS.pptx
DATA MODELS.pptx
 
oracle
oracle oracle
oracle
 
DBMS ppts unit1.pptx
DBMS ppts  unit1.pptxDBMS ppts  unit1.pptx
DBMS ppts unit1.pptx
 
Week 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptxWeek 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptx
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Different data models
Different data modelsDifferent data models
Different data models
 
Specifying data requirments
Specifying data requirmentsSpecifying data requirments
Specifying data requirments
 
Lecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptxLecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptx
 
ER modeling
ER modelingER modeling
ER modeling
 
SQL Tutorial - Basics of Structured Query Language Day 1.pdf
SQL Tutorial - Basics of Structured Query Language Day 1.pdfSQL Tutorial - Basics of Structured Query Language Day 1.pdf
SQL Tutorial - Basics of Structured Query Language Day 1.pdf
 
Data warehouse 17 dimensional data model
Data warehouse 17 dimensional data modelData warehouse 17 dimensional data model
Data warehouse 17 dimensional data model
 
relational database
relational databaserelational database
relational database
 
ch2-slide Data Models.pptx
ch2-slide Data Models.pptxch2-slide Data Models.pptx
ch2-slide Data Models.pptx
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
T-SQL
T-SQLT-SQL
T-SQL
 
Module 1 - Chapter 2.pptx
Module 1 - Chapter 2.pptxModule 1 - Chapter 2.pptx
Module 1 - Chapter 2.pptx
 
Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptx
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
 

More from Ismail Mukiibi

IP/MAC Address Translation
IP/MAC Address TranslationIP/MAC Address Translation
IP/MAC Address TranslationIsmail Mukiibi
 
Traffic Characterization
Traffic CharacterizationTraffic Characterization
Traffic CharacterizationIsmail Mukiibi
 
Microprocessor application (Introduction)
Microprocessor application (Introduction)Microprocessor application (Introduction)
Microprocessor application (Introduction)Ismail Mukiibi
 
Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2Ismail Mukiibi
 
Advanced computer architect lesson 3 and 4
Advanced computer architect lesson 3 and 4Advanced computer architect lesson 3 and 4
Advanced computer architect lesson 3 and 4Ismail Mukiibi
 
Advanced computer architecture lesson 5 and 6
Advanced computer architecture lesson 5 and 6Advanced computer architecture lesson 5 and 6
Advanced computer architecture lesson 5 and 6Ismail Mukiibi
 
Pc hardware course work
Pc hardware course workPc hardware course work
Pc hardware course workIsmail Mukiibi
 
Mac addresses(media access control)
Mac addresses(media access control)Mac addresses(media access control)
Mac addresses(media access control)Ismail Mukiibi
 
Why building collapse in kampala
Why building collapse in kampalaWhy building collapse in kampala
Why building collapse in kampalaIsmail Mukiibi
 

More from Ismail Mukiibi (12)

Quality of service
Quality of serviceQuality of service
Quality of service
 
IP/MAC Address Translation
IP/MAC Address TranslationIP/MAC Address Translation
IP/MAC Address Translation
 
Traffic Characterization
Traffic CharacterizationTraffic Characterization
Traffic Characterization
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Html notes
Html notesHtml notes
Html notes
 
Microprocessor application (Introduction)
Microprocessor application (Introduction)Microprocessor application (Introduction)
Microprocessor application (Introduction)
 
Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2
 
Advanced computer architect lesson 3 and 4
Advanced computer architect lesson 3 and 4Advanced computer architect lesson 3 and 4
Advanced computer architect lesson 3 and 4
 
Advanced computer architecture lesson 5 and 6
Advanced computer architecture lesson 5 and 6Advanced computer architecture lesson 5 and 6
Advanced computer architecture lesson 5 and 6
 
Pc hardware course work
Pc hardware course workPc hardware course work
Pc hardware course work
 
Mac addresses(media access control)
Mac addresses(media access control)Mac addresses(media access control)
Mac addresses(media access control)
 
Why building collapse in kampala
Why building collapse in kampalaWhy building collapse in kampala
Why building collapse in kampala
 

Recently uploaded

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 

Relational database (Unit 2)

  • 1. Relational Database • Relations can be represented as two-dimensional data tables with rows and columns. • The rows of a relation are called tuples. • The columns of a relation are called attributes. • The attributes draw values from a domain (a legal pool of values). • The number of tuples in a relation is called its cardinality while the number of attributes in a relation is called its degree. • A relation also consists of a schema and an instance. • Schema defines the structure of a relation which consists of a fixed set of attribute-domain pairs. • An instance of a relation is a time-varying set of tuples where each tuple consists of attribute-value pairs. Constraints: Set of rules for the database is known as constraints • Domain Constraints: Restrictions on the set of values of the attribute can take can be specified. • Key Constraints: A relation is defined to be set of tuples, since a set does not contain duplicates, no two tuples can be identical. • Entity Integrity Constraints: Are the set of rules called by the application and these are applicable on all instances of the relations • Referential Integrity Constraint: This is a special type of integrity constraint that relates two relations and maintains consistency across the relations. Data Integrity Data Integrity falls into the following categories: • Entity integrity Entity integrity ensures that each row can be uniquely identified by an attribute called the Primary key. The Primary key cannot have a NULL value.
  • 2. • Domain integrity Domain integrity refers to the range of valid entries for a given column. It ensures that there are only valid entries in the column. • Referential integrity Referential integrity ensures that for every value of a Foreign key, there is a matching value of the Primary key. Relational Algebra • Relational Algebra is a procedural language used for manipulating relations. • The relational model gives the structure for relations so that data can be stored in that format but relational algebra enables us to retrieve information from relations. The operators of Relational Algebra are: • Select: This is a unary operator that select a subset of tuples of the relation, which satisfy selection condition. This can be represented by • Project: This is also a unary operator, that chooses subset of attributes or columns of a relation and restricts all the tuples of a relation to those attributes. This is represented by The operators of Relational Algebra are: • Cartesian Product: This is a binary operator that combines information across two relations. Cartesian product of two relations
  • 3. R = (A1, A2, A3, A4, ….) and S = (B1, B2, B3,…) can be represented as: Q = R X S = (A1, A2, A3, ….. B1, B2, B3,…). • Join: This is also a binary operator which is widely used and this operator concatenates only tuples that satisfy certain conditions. This is represented by: Union, Intersection and Difference: • To have union relations must have same number of attributes and corresponding attributes must have same domain. • Also since the result of each of these operators has to be a relation, duplicates are removed. Database Planning • The database design should be adequate for serving different applications. • Improper database planning will result in loss of data interrelationship, repeatability of data, loss of data share, loss of control on data etc. Basically one can classify the needs into three categories as below: • Operational database, which contains data assisting day to day activities of the organization. Ex.: sales, product stock, etc. • Control database, which contains data assisting needs of middle management to monitor and control business activities by effective and efficient management of men, machines and money. For example: monthly performance summaries, sales statements etc. • Strategic planning database, which contains data required for top management for taking long-term decisions like economic policies of government, similar type of organisation etc. Steps in Database Planning • Before designing the database certain decision has to be taken regarding approach and type of database.
  • 4. • An organisation may go for single large global database or separate databases serving different groups of applications. Single global database • Results from total systems approach where requirements of entire organisation and business functions are inter-related. • This results in minimum redundancy and maximum of data. • This also allows full control over the data design and access. • This approach results in more complex database having large number of data types and relationships and requires considerable time and effort in design and implementation. Multiple database approach • Reduces time and effort required for design and lesser risk in database management. • However this approach may lead to problems in sharing of data and inter- operability. A database can be designed using top-down and bottom-up approach. Top-down approach • Starts with enterprise level model, preparing data model for entire application domain. • This approach does not consider specific details of processing. • The ER model is prepared identifying the main entities and relationships. • With this approach, there is a possibility of not accounting all user requirements, missing certain entities or relationships. Bottom-up approach • Begins with individual user requirements. • Data model for each requirement is prepared understating the inputs, outputs and process. • These individual models then merged into a single conceptual schema.
  • 5. • The main disadvantage of this approach is it fails to take into account future requirements. After deciding on the approach, planning is carried out for database design. The important points to be kept in mind while planning are as listed below: • Decide on the business steps, which will make use of database. • Establish database administrative function. • Perform business system analysis • Build information model • Developing data distribution plan. • Develop Implementation Plan. • Review. Database Design Some guidelines to be followed while designing the database: • A database design should be unambiguous and easy to understand. • It should avoid / reduce the redundancy. • Unrelated data should be in separate table so that updating the data will be easy. • Design should have no inconsistencies. • An entity should have attributes, which are generally present for all its instances. Minimise null values to the attributes in the design. • Define constraints so that correctness of data will be ensured. • Design should facilitate information addition in future. • Maintenance should be easy. • Some of these can be translated into design principles for good relations.
  • 6. From the point of view of user, important criteria for designing are: • Meaningful grouping of attributes • No redundancy • No inapplicable attributes • Uniformity in naming and definitions of the data items. Conversion of ER Diagram to Relations • The ER model represents the conceptual entities and their interrelationships at a logical level. • Using some simple rules one can convert ER model to relational database. • The relational database obtained in this approach will avoid redundancies and update anomalies. • This is possible only if ER diagram is drawn correctly. The rules, which are to be followed to derive the relational model from the ER diagram, are: • Define a table for each strong entity where the table has one column for each simple attribute. The key of the table will be key of the entity itself. • Define a table for each weak entity. It will contain the primary key of the strong entity on which it depends, and it will also include attributes of the weak entity. • Define a table for each relationship where the table consists of the primary keys of the participating entity sets and the attributes of the relationship itself. • For one to one relationships, it is not necessary to define a separate table. • Try to avoid defining a separate table for many to one binary relationship. • Consider the example of student and course. • Here the relationship is many to many. • From the above rules, we can define three tables for this situation namely student entity, course entity and study relationship.