Relational database (Unit 2)

Ismail Mukiibi
Ismail MukiibiSoftware Developer, Tech Support em Medic Software, Uganda LTD

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).

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

Recomendados

Relational data base management system (Unit 1) por
Relational data base management system (Unit 1)Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Ismail Mukiibi
258 visualizações12 slides
Compare peer por
Compare peerCompare peer
Compare peerIsmail Mukiibi
1.3K visualizações3 slides
Kinds of networks por
Kinds of networksKinds of networks
Kinds of networksIsmail Mukiibi
1.1K visualizações18 slides
Unit 1 dbms por
Unit 1 dbmsUnit 1 dbms
Unit 1 dbmsSweta Singh
102 visualizações39 slides
DBMS & Data Models - In Introduction por
DBMS & Data Models - In IntroductionDBMS & Data Models - In Introduction
DBMS & Data Models - In IntroductionRajeev Srivastava
668 visualizações24 slides
Introduction to Database Management Systems (DBMS) por
Introduction to Database Management Systems (DBMS)Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Vijayananda Ratnam Ch
84 visualizações51 slides

Mais conteúdo relacionado

Mais procurados

Fundamentals of Database ppt ch01 por
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Jotham Gadot
75.1K visualizações52 slides
Data base management system por
Data base management systemData base management system
Data base management systemNavneet Jingar
32K visualizações37 slides
Assignment on dbms por
Assignment on dbmsAssignment on dbms
Assignment on dbmsMohd Arif
9.6K visualizações15 slides
Chapter 9 por
Chapter 9Chapter 9
Chapter 9Ahmed Magdy
1.8K visualizações48 slides
Database system architecture por
Database system architectureDatabase system architecture
Database system architectureDk Rukshan
14.7K visualizações10 slides
Chapter1 por
Chapter1Chapter1
Chapter1Jafar Nesargi
5K visualizações27 slides

Mais procurados(18)

Fundamentals of Database ppt ch01 por Jotham Gadot
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01
Jotham Gadot75.1K visualizações
Data base management system por Navneet Jingar
Data base management systemData base management system
Data base management system
Navneet Jingar32K visualizações
Assignment on dbms por Mohd Arif
Assignment on dbmsAssignment on dbms
Assignment on dbms
Mohd Arif9.6K visualizações
Chapter 9 por Ahmed Magdy
Chapter 9Chapter 9
Chapter 9
Ahmed Magdy1.8K visualizações
Database system architecture por Dk Rukshan
Database system architectureDatabase system architecture
Database system architecture
Dk Rukshan14.7K visualizações
Chapter1 por Jafar Nesargi
Chapter1Chapter1
Chapter1
Jafar Nesargi5K visualizações
DBMS - RAID por MythiliMurugan3
DBMS - RAIDDBMS - RAID
DBMS - RAID
MythiliMurugan32.1K visualizações
Database management system by Gursharan singh por Gursharan Singh
Database management system by Gursharan singhDatabase management system by Gursharan singh
Database management system by Gursharan singh
Gursharan Singh333 visualizações
Data abstraction in DBMS por Papan Sarkar
Data abstraction in DBMSData abstraction in DBMS
Data abstraction in DBMS
Papan Sarkar1.1K visualizações
Dbms Networks por Sagar Morakhia
Dbms NetworksDbms Networks
Dbms Networks
Sagar Morakhia882 visualizações
Relational database oracle por jamunaashok
Relational database  oracleRelational database  oracle
Relational database oracle
jamunaashok104 visualizações
Dbms por Tej Kiran
DbmsDbms
Dbms
Tej Kiran282 visualizações
Slide 4 dbms users por Visakh V
Slide 4 dbms usersSlide 4 dbms users
Slide 4 dbms users
Visakh V665 visualizações
Lesson 1 data processing por guevarra_2000
Lesson 1   data processing Lesson 1   data processing
Lesson 1 data processing
guevarra_20004.4K visualizações
Architec design introduction por Dr.Jayanthi ramasamy
Architec design introductionArchitec design introduction
Architec design introduction
Dr.Jayanthi ramasamy269 visualizações

Similar a Relational database (Unit 2)

Unit 2_DBMS_10.2.22.pptx por
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxMaryJoseph79
6 visualizações106 slides
DBMS data modeling.pptx por
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptxMrwafaAbbas
12 visualizações16 slides
DATA MODELS.pptx por
DATA MODELS.pptxDATA MODELS.pptx
DATA MODELS.pptxNithyasri Arumugam
6 visualizações27 slides
oracle por
oracle oracle
oracle Vilasita Nandamuri
1.6K visualizações129 slides
DBMS ppts unit1.pptx por
DBMS ppts  unit1.pptxDBMS ppts  unit1.pptx
DBMS ppts unit1.pptxVaibhavSaluja1
13 visualizações156 slides
Database Management System por
Database Management SystemDatabase Management System
Database Management SystemSelshaCs
121 visualizações22 slides

Similar a Relational database (Unit 2)(20)

Unit 2_DBMS_10.2.22.pptx por MaryJoseph79
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptx
MaryJoseph796 visualizações
DBMS data modeling.pptx por MrwafaAbbas
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptx
MrwafaAbbas12 visualizações
DBMS ppts unit1.pptx por VaibhavSaluja1
DBMS ppts  unit1.pptxDBMS ppts  unit1.pptx
DBMS ppts unit1.pptx
VaibhavSaluja113 visualizações
Database Management System por SelshaCs
Database Management SystemDatabase Management System
Database Management System
SelshaCs121 visualizações
Different data models por madhusha udayangani
Different data modelsDifferent data models
Different data models
madhusha udayangani28.4K visualizações
Specifying data requirments por Imran60577
Specifying data requirmentsSpecifying data requirments
Specifying data requirments
Imran605773 visualizações
Lecture 1. Data Structure & Algorithm.pptx por ArifKamal36
Lecture 1. Data Structure & Algorithm.pptxLecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptx
ArifKamal364 visualizações
Data warehouse 17 dimensional data model por Vaibhav Khanna
Data warehouse 17 dimensional data modelData warehouse 17 dimensional data model
Data warehouse 17 dimensional data model
Vaibhav Khanna76 visualizações
relational database por Surya Swaroop
relational databaserelational database
relational database
Surya Swaroop56 visualizações
ch2-slide Data Models.pptx por TamiratDejene1
ch2-slide Data Models.pptxch2-slide Data Models.pptx
ch2-slide Data Models.pptx
TamiratDejene12 visualizações
Chapter-5 The Relational Data Model por Kunal Anand
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
Kunal Anand108 visualizações
T-SQL por LuisDeLeon74
T-SQLT-SQL
T-SQL
LuisDeLeon741.2K visualizações
Module 1 - Chapter 2.pptx por SoniaDevi15
Module 1 - Chapter 2.pptxModule 1 - Chapter 2.pptx
Module 1 - Chapter 2.pptx
SoniaDevi155 visualizações
Week 2 - Database System Development Lifecycle-old.pptx por NurulIzrin
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptx
NurulIzrin12 visualizações
DATABASE DESIGN.pptx por SaranCreations
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
SaranCreations3 visualizações
Ch1_Intro-95(1).ppt por RAJULKUMARSUTHAR
Ch1_Intro-95(1).pptCh1_Intro-95(1).ppt
Ch1_Intro-95(1).ppt
RAJULKUMARSUTHAR51 visualizações

Mais de Ismail Mukiibi

Quality of service por
Quality of serviceQuality of service
Quality of serviceIsmail Mukiibi
588 visualizações83 slides
IP/MAC Address Translation por
IP/MAC Address TranslationIP/MAC Address Translation
IP/MAC Address TranslationIsmail Mukiibi
244 visualizações14 slides
Traffic Characterization por
Traffic CharacterizationTraffic Characterization
Traffic CharacterizationIsmail Mukiibi
543 visualizações30 slides
PHP POWERPOINT SLIDES por
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESIsmail Mukiibi
3.9K visualizações19 slides
Html notes por
Html notesHtml notes
Html notesIsmail Mukiibi
48.1K visualizações47 slides
Microprocessor application (Introduction) por
Microprocessor application (Introduction)Microprocessor application (Introduction)
Microprocessor application (Introduction)Ismail Mukiibi
4.7K visualizações45 slides

Mais de Ismail Mukiibi(12)

Quality of service por Ismail Mukiibi
Quality of serviceQuality of service
Quality of service
Ismail Mukiibi588 visualizações
IP/MAC Address Translation por Ismail Mukiibi
IP/MAC Address TranslationIP/MAC Address Translation
IP/MAC Address Translation
Ismail Mukiibi244 visualizações
Traffic Characterization por Ismail Mukiibi
Traffic CharacterizationTraffic Characterization
Traffic Characterization
Ismail Mukiibi543 visualizações
PHP POWERPOINT SLIDES por Ismail Mukiibi
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
Ismail Mukiibi3.9K visualizações
Html notes por Ismail Mukiibi
Html notesHtml notes
Html notes
Ismail Mukiibi48.1K visualizações
Microprocessor application (Introduction) por Ismail Mukiibi
Microprocessor application (Introduction)Microprocessor application (Introduction)
Microprocessor application (Introduction)
Ismail Mukiibi4.7K visualizações
Advanced computer architecture lesson 1 and 2 por Ismail Mukiibi
Advanced computer architecture lesson 1 and 2Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2
Ismail Mukiibi4.8K visualizações
Advanced computer architect lesson 3 and 4 por Ismail Mukiibi
Advanced computer architect lesson 3 and 4Advanced computer architect lesson 3 and 4
Advanced computer architect lesson 3 and 4
Ismail Mukiibi6.5K visualizações
Advanced computer architecture lesson 5 and 6 por Ismail Mukiibi
Advanced computer architecture lesson 5 and 6Advanced computer architecture lesson 5 and 6
Advanced computer architecture lesson 5 and 6
Ismail Mukiibi7.6K visualizações
Pc hardware course work por Ismail Mukiibi
Pc hardware course workPc hardware course work
Pc hardware course work
Ismail Mukiibi329 visualizações
Mac addresses(media access control) por Ismail Mukiibi
Mac addresses(media access control)Mac addresses(media access control)
Mac addresses(media access control)
Ismail Mukiibi10.2K visualizações
Why building collapse in kampala por Ismail Mukiibi
Why building collapse in kampalaWhy building collapse in kampala
Why building collapse in kampala
Ismail Mukiibi867 visualizações

Último

.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV por
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTVSplunk
86 visualizações20 slides
Understanding GenAI/LLM and What is Google Offering - Felix Goh por
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix GohNUS-ISS
39 visualizações33 slides
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... por
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...NUS-ISS
15 visualizações28 slides
Top 10 Strategic Technologies in 2024: AI and Automation por
Top 10 Strategic Technologies in 2024: AI and AutomationTop 10 Strategic Technologies in 2024: AI and Automation
Top 10 Strategic Technologies in 2024: AI and AutomationAutomationEdge Technologies
13 visualizações14 slides
Special_edition_innovator_2023.pdf por
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
14 visualizações6 slides
Spesifikasi Lengkap ASUS Vivobook Go 14 por
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14Dot Semarang
35 visualizações1 slide

Último(20)

.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV por Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk86 visualizações
Understanding GenAI/LLM and What is Google Offering - Felix Goh por NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS39 visualizações
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... por NUS-ISS
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
NUS-ISS15 visualizações
Top 10 Strategic Technologies in 2024: AI and Automation por AutomationEdge Technologies
Top 10 Strategic Technologies in 2024: AI and AutomationTop 10 Strategic Technologies in 2024: AI and Automation
Top 10 Strategic Technologies in 2024: AI and Automation
AutomationEdge Technologies13 visualizações
Special_edition_innovator_2023.pdf por WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2214 visualizações
Spesifikasi Lengkap ASUS Vivobook Go 14 por Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 visualizações
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor... por Vadym Kazulkin
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
Vadym Kazulkin70 visualizações
Voice Logger - Telephony Integration Solution at Aegis por Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 visualizações
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze por NUS-ISS
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
NUS-ISS19 visualizações
Transcript: The Details of Description Techniques tips and tangents on altern... por BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada119 visualizações
Attacking IoT Devices from a Web Perspective - Linux Day por Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 visualizações
Perth MeetUp November 2023 por Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price12 visualizações
How the World's Leading Independent Automotive Distributor is Reinventing Its... por NUS-ISS
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...
NUS-ISS15 visualizações
Empathic Computing: Delivering the Potential of the Metaverse por Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst449 visualizações
Combining Orchestration and Choreography for a Clean Architecture por ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs168 visualizações
Black and White Modern Science Presentation.pptx por maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 visualizações
Report 2030 Digital Decade por Massimo Talia
Report 2030 Digital DecadeReport 2030 Digital Decade
Report 2030 Digital Decade
Massimo Talia13 visualizações
Data-centric AI and the convergence of data and model engineering: opportunit... por Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier29 visualizações
Roadmap to Become Experts.pptx por dscwidyatamanew
Roadmap to Become Experts.pptxRoadmap to Become Experts.pptx
Roadmap to Become Experts.pptx
dscwidyatamanew11 visualizações
Uni Systems for Power Platform.pptx por Uni Systems S.M.S.A.
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptx
Uni Systems S.M.S.A.38 visualizações

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.