SlideShare a Scribd company logo
1 of 42
MySQL Exception & Database
Jamshid Hashimi
Trainer, Cresco Solution
http://www.jamshidhashimi.com
jamshid@netlinks.af
@jamshidhashimi
ajamshidhashimi
Afghanistan Workforce
Development Program
Agenda
• Error
• Exception
• About Database & Hierarchical Model
• Specialization, Generalization & Aggregation
• Database Normalization
• Relationships
Error
• Error handling is important
– First, it lets the user know, in a relatively friendly
manner, that something has gone wrong and that
they should contact the technical support
department or that someone from tech support
has been notified.
– Second it allows the programmer to put in some
niceties to aid in the debugging of issues.
Error
• mysqli_connect_errno()
– Returns the error code from the last connection error
• mysqli_connect_error()
– Returns the error description from the last connection error
• mysqli_errno()
– Returns the last error code for the most recent function call
• mysqli_error_list()
– Returns a list of errors for the most recent function call
• mysqli_error()
– Returns the last error description for the most recent function
call
Exception
• With PHP 5 came a new object oriented way
of dealing with errors.
• Exception handling is used to change the
normal flow of the code execution if a
specified error (exceptional) condition occurs.
This condition is called an exception.
Exception
$arr = array(23,44,55,77,88,99);
try{
if(in_array(4,$arr)){
echo "FOUND";
}else{
throw new exception("4 not found in the array");
}
if(is_array($arr)){
echo "TRUE";
}else{
throw new customException("It is not an array");
}
}
catch(exception $e){
echo "Error occured in the file: ".$e->getFile()." and in line
".$e->getLine()." with a message: ".$e->getMessage();
}
catch(customException $e){
echo $e->errorMessage();
}
Database
• A database is an organized collection of
information. Small businesses can use databases
in a number of different ways. A database can
help you organize information about your
customers and clients. A database can contain
information about your product inventory. A
database can track sales, expenses and other
financial information.
• In a database an entity type is the equivalent of a
table. Each individual record is represented as a
row, and each attribute as a column.
Hierarchical Database Model
• IBM introduced the first generation of
database technology, known as hierarchical,
when it installed IMS (Information
Management System ) in its mainframe
computers in the mid-1960s. This technology
was upgraded in the mid-1970s to network
database technology. Both hierarchical and
network databases are often described by the
term hierarchical database.
Hierarchical Database Model
Hierarchical Database Model
• The structure allows representing information using
parent/child relationships: each parent can have many
children, but each child has only one parent (also known as
a 1-to-many relationship). All attributes of a specific record
are listed under an entity type.
• Currently the most widely used hierarchical databases are
IMS developed by IBM and Windows Registry by Microsoft.
• Mother–child relationship: Child may only have one mother
but a mother can have multiple children. Mothers and
children are tied together by links called "pointers". A
mother will have a list of pointers to each of her children.
Hierarchical Database Model
• "Hierarchical database systems are difficult to
use. They require application developers to
program navigation through the connected
records [...]
• "They also require developers to predict all
possible access patterns in advance and
design the database accordingly. A database
access pattern that is not included in the
design becomes very difficult and inefficient."
Aggregation
• Aggregation
– The aggregation is an abstraction concept, which
is used to build higher-level object (object as a
whole) from its components. For example, a
computer is built by using various related
components.
Aggregation
• The aggregation abstraction allows the
designer to either decompose objects by
breaking them into more detailed components
or to aggregate objects, grouping them
together into higher-level objects.
Decomposition is simply the. opposite process
to aggregation. Both processes are considered
the part of the aggregation abstraction.
Generalization
• Generalization is another powerful
abstraction. Generalization allows entities of
different types to be considered as examples
of a higher level set. It means that combining
different types of entities (or objects) into a
higher-level set or in more general entity
types is called generalization.
– For example, electronic device is a more general
entity type of electronic objects like computer, TV
set etc.
Specialization
• Categorizing the entities (or objects) in the set
according to their roles in a relationship, is
called specialization. Specialization is the
process of defining a set of subclasses of an
entity. The set of subclasses that form a
specialization are defined on the basis of
some distinguishing characteristics of the
entities in the super-class.
Specialization
• Clerk, manager, and programmer
– super-class 'Employee’
• An entity may have several specializations.
– EMPLOYEE
• 'Permanent-Employee'
• 'Temporary-Employee'
Database Normalization
• Normalization is the process of efficiently
organizing data in a database.
• There are two goals of the normalization
process:
– Eliminating redundant data (for example, storing
the same data in more than one table)
– Ensuring data dependencies make sense (only
storing related data in a table).
Database Normalization
• First Normal Form (1NF): First normal form
(1NF) sets the very basic rules for an organized
database:
– Eliminate duplicative columns from the same
table.
– Create separate tables for each group of related
data and identify each row with a unique column
or set of columns (the primary key).
Database Normalization
Database Normalization
Database Normalization
• Second Normal Form (2NF): Second normal
form (2NF) further addresses the concept of
removing duplicative data:
– Meet all the requirements of the first normal
form.
– Remove subsets of data that apply to multiple
rows of a table and place them in separate tables.
– Create relationships between these new tables
and their predecessors through the use of foreign
keys.
Database Normalization
Database Normalization
Database Normalization
• Third normal form (3NF) goes one large step
further:
– Meet all the requirements of the second normal
form.
– There is no transitive functional dependency
Database Normalization
Database Normalization
Database Normalization
• The Boyce-Codd Normal Form, also referred to
as the "third and half (3.5) normal form", adds
one more requirement:
– Meet all the requirements of the third normal
form.
– Every determinant must be a candidate key.
Database Normalization
• In order to convert a table to BCNF, we must:
1. Find and remove the overlapping candidate
keys. Place the part of the candidate key and
the attribute it is functionally dependent on,
in a different table.
2. Group the remaining items into a table.
• Suppose we have five columns in a table.
Primary Key
Database Normalization
• but column C can determine the value of column
B.
• In other words, the value of Column B is
determined by the Column C then this table can
not be in the Boyce - Codd Normal Form.
Database Normalization
• To convert this table into BCNF, we need to
divide into two tables.
• The table1 contains the following columns.
• where primary key is the combination of the
column A and B
Database Normalization
• And table2 will contain the two columns.
• where C will be the primary key.
• Thus every table satisfying the 3NF condition
cannot be said to be in BCNF normal form but a
table in BCNF will always be in 3NF form.
Database Normalization
• Consider the following non-BCNF table:
The candidate keys of the table are:
• {Person, Shop Type}
• {Person, Nearest Shop}
Database Normalization
Why it is not BCNF?
• The violation of BCNF means that the table is subject to
anomalies. For example, Eagle Eye might have its Shop
Type changed to "Optometrist" on its "Fuller" record
while retaining the Shop Type "Optician" on its
"Davidson" record.
Database Normalization
How to convert itn
into BCNF?
Database Normalization
• After normalization
Candidate keys are {person, shop}
and{shop},respectively.
Database Normalization
Database Normalization
• Fourth Normal Form (4NF): Finally, fourth
normal form (4NF) has one additional
requirement:
– Meet all the requirements of the third normal
form.
– A relation is in 4NF if it has no multi-valued
dependencies.
Database Normalization
Database Normalization
Relationship
• One-to-one relationships: Occur when each entry in the first table has one, and
only one, counterpart in the second table.
– One-to-one relationships are rarely used because it is often more efficient to simply put all of
the information in a single table.
• One-to-many relationships: Are the most common type of database relationship.
They occur when each record in the first table corresponds to one or more records
in the second table but each record in the second table corresponds to only one
record in the first table.
– For example, the relationship between a Teachers table and a Students table in an elementary
school database would likely be a one-to-many relationship, because each student has only
one teacher, but each teacher may have multiple students.
• Many-to-many relationships: Occur when each record in the first table
corresponds to one or more records in the second table and each record in the
second table corresponds to one or more records in the first table.
– For example, the relationship between a Teachers and a Courses table would likely be many-
to-many because each teacher may instruct more than one course and each course may have
more than one instructor.
ASSIGNMENT
QUESTIONS?

More Related Content

What's hot

The relational database model
The relational database modelThe relational database model
The relational database modelDhani Ahmad
 
Unit 4 rdbms study_material
Unit 4  rdbms study_materialUnit 4  rdbms study_material
Unit 4 rdbms study_materialgayaramesh
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignArchit Saxena
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
database management system
database management systemdatabase management system
database management systemNivetha Ganesan
 
Intro To DataBase
Intro To DataBaseIntro To DataBase
Intro To DataBaseDevMix
 
DBMS - Relational Model
DBMS - Relational ModelDBMS - Relational Model
DBMS - Relational ModelOvais Imtiaz
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design Jayant Dalvi
 
Normalization
NormalizationNormalization
Normalizationlingesan
 
Database Design
Database DesignDatabase Design
Database Designlearnt
 
Week 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data ModelWeek 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data Modeloudesign
 
Introduction to DBMS and SQL Overview
Introduction to DBMS and SQL OverviewIntroduction to DBMS and SQL Overview
Introduction to DBMS and SQL OverviewPrabu U
 

What's hot (18)

DISE - Database Concepts
DISE - Database ConceptsDISE - Database Concepts
DISE - Database Concepts
 
The relational database model
The relational database modelThe relational database model
The relational database model
 
Unit 4 rdbms study_material
Unit 4  rdbms study_materialUnit 4  rdbms study_material
Unit 4 rdbms study_material
 
RDBMS concepts
RDBMS conceptsRDBMS concepts
RDBMS concepts
 
Database intro
Database introDatabase intro
Database intro
 
RDMS AND SQL
RDMS AND SQLRDMS AND SQL
RDMS AND SQL
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
database management system
database management systemdatabase management system
database management system
 
Rdbms
RdbmsRdbms
Rdbms
 
Intro To DataBase
Intro To DataBaseIntro To DataBase
Intro To DataBase
 
DBMS - Relational Model
DBMS - Relational ModelDBMS - Relational Model
DBMS - Relational Model
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
 
Normalization
NormalizationNormalization
Normalization
 
RDBMS with MySQL
RDBMS with MySQLRDBMS with MySQL
RDBMS with MySQL
 
Database Design
Database DesignDatabase Design
Database Design
 
Week 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data ModelWeek 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data Model
 
Introduction to DBMS and SQL Overview
Introduction to DBMS and SQL OverviewIntroduction to DBMS and SQL Overview
Introduction to DBMS and SQL Overview
 

Viewers also liked

Hierarchical visual filtering pragmatic and epistemic actions for database vi...
Hierarchical visual filtering pragmatic and epistemic actions for database vi...Hierarchical visual filtering pragmatic and epistemic actions for database vi...
Hierarchical visual filtering pragmatic and epistemic actions for database vi...Universidade de São Paulo
 
Techniques for effective and efficient fire detection from social media images
Techniques for effective and efficient fire detection from social media imagesTechniques for effective and efficient fire detection from social media images
Techniques for effective and efficient fire detection from social media imagesUniversidade de São Paulo
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ARADHYAYANA
 

Viewers also liked (6)

Hierarchical visual filtering pragmatic and epistemic actions for database vi...
Hierarchical visual filtering pragmatic and epistemic actions for database vi...Hierarchical visual filtering pragmatic and epistemic actions for database vi...
Hierarchical visual filtering pragmatic and epistemic actions for database vi...
 
Techniques for effective and efficient fire detection from social media images
Techniques for effective and efficient fire detection from social media imagesTechniques for effective and efficient fire detection from social media images
Techniques for effective and efficient fire detection from social media images
 
Dbms mca-section a
Dbms mca-section aDbms mca-section a
Dbms mca-section a
 
Types dbms
Types dbmsTypes dbms
Types dbms
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 

Similar to Exception & Database

Presentation DBMS (1)
Presentation DBMS (1)Presentation DBMS (1)
Presentation DBMS (1)Ali Raza
 
Info systems databases
Info systems databasesInfo systems databases
Info systems databasesMR Z
 
dbms Unit 1.pdf arey bhai teri maa chodunga
dbms Unit 1.pdf arey bhai teri maa chodungadbms Unit 1.pdf arey bhai teri maa chodunga
dbms Unit 1.pdf arey bhai teri maa chodungaVaradKadtan1
 
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
 
UNIT machine learning unit 1,algorithm pdf
UNIT machine learning  unit 1,algorithm pdfUNIT machine learning  unit 1,algorithm pdf
UNIT machine learning unit 1,algorithm pdfOmarFarooque9
 
Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)Zhang Bo
 
Data massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodesData massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodesUlf Wendel
 
Arinda oktaviana 11353204810 vii lokal g
Arinda oktaviana 11353204810   vii lokal gArinda oktaviana 11353204810   vii lokal g
Arinda oktaviana 11353204810 vii lokal gArinda oktaviana
 
Database management system.pptx
Database management system.pptxDatabase management system.pptx
Database management system.pptxAshmitKashyap1
 
Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Vijayananda Ratnam Ch
 
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
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Dios Kurniawan
 

Similar to Exception & Database (20)

Presentation DBMS (1)
Presentation DBMS (1)Presentation DBMS (1)
Presentation DBMS (1)
 
Info systems databases
Info systems databasesInfo systems databases
Info systems databases
 
DBMS
DBMS DBMS
DBMS
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
dbms Unit 1.pdf arey bhai teri maa chodunga
dbms Unit 1.pdf arey bhai teri maa chodungadbms Unit 1.pdf arey bhai teri maa chodunga
dbms Unit 1.pdf arey bhai teri maa chodunga
 
Dbms unit 1
Dbms unit 1Dbms unit 1
Dbms unit 1
 
Fundamentals of DBMS
Fundamentals of DBMSFundamentals of DBMS
Fundamentals of DBMS
 
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
 
database1.pdf
database1.pdfdatabase1.pdf
database1.pdf
 
Unit 2 DATABASE ESSENTIALS.pptx
Unit 2 DATABASE ESSENTIALS.pptxUnit 2 DATABASE ESSENTIALS.pptx
Unit 2 DATABASE ESSENTIALS.pptx
 
unit 1.pdf
unit 1.pdfunit 1.pdf
unit 1.pdf
 
UNIT machine learning unit 1,algorithm pdf
UNIT machine learning  unit 1,algorithm pdfUNIT machine learning  unit 1,algorithm pdf
UNIT machine learning unit 1,algorithm pdf
 
Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)
 
Data massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodesData massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodes
 
Arinda oktaviana 11353204810 vii lokal g
Arinda oktaviana 11353204810   vii lokal gArinda oktaviana 11353204810   vii lokal g
Arinda oktaviana 11353204810 vii lokal g
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
Database management system.pptx
Database management system.pptxDatabase management system.pptx
Database management system.pptx
 
Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)
 
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
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1
 

More from Jamshid Hashimi

Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Jamshid Hashimi
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Jamshid Hashimi
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0Jamshid Hashimi
 
RIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyRIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyJamshid Hashimi
 
How Coding Can Make Your Life Better
How Coding Can Make Your Life BetterHow Coding Can Make Your Life Better
How Coding Can Make Your Life BetterJamshid Hashimi
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better CodeJamshid Hashimi
 
Launch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationLaunch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationJamshid Hashimi
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to BloggingJamshid Hashimi
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to WordpressJamshid Hashimi
 
CodeIgniter Helper Functions
CodeIgniter Helper FunctionsCodeIgniter Helper Functions
CodeIgniter Helper FunctionsJamshid Hashimi
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class ReferenceJamshid Hashimi
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniterJamshid Hashimi
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterJamshid Hashimi
 

More from Jamshid Hashimi (20)

Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0
 
RIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyRIST - Research Institute for Science and Technology
RIST - Research Institute for Science and Technology
 
How Coding Can Make Your Life Better
How Coding Can Make Your Life BetterHow Coding Can Make Your Life Better
How Coding Can Make Your Life Better
 
Mobile Vision
Mobile VisionMobile Vision
Mobile Vision
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better Code
 
Launch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationLaunch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media Integration
 
Customizing Your Blog 2
Customizing Your Blog 2Customizing Your Blog 2
Customizing Your Blog 2
 
Customizing Your Blog 1
Customizing Your Blog 1Customizing Your Blog 1
Customizing Your Blog 1
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to Blogging
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
 
CodeIgniter Helper Functions
CodeIgniter Helper FunctionsCodeIgniter Helper Functions
CodeIgniter Helper Functions
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class Reference
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniter
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter Practice
 
CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
MySQL Record Operations
MySQL Record OperationsMySQL Record Operations
MySQL Record Operations
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
 

Recently uploaded

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
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
 

Recently uploaded (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
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?
 

Exception & Database

  • 1. MySQL Exception & Database Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com jamshid@netlinks.af @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program
  • 2. Agenda • Error • Exception • About Database & Hierarchical Model • Specialization, Generalization & Aggregation • Database Normalization • Relationships
  • 3. Error • Error handling is important – First, it lets the user know, in a relatively friendly manner, that something has gone wrong and that they should contact the technical support department or that someone from tech support has been notified. – Second it allows the programmer to put in some niceties to aid in the debugging of issues.
  • 4. Error • mysqli_connect_errno() – Returns the error code from the last connection error • mysqli_connect_error() – Returns the error description from the last connection error • mysqli_errno() – Returns the last error code for the most recent function call • mysqli_error_list() – Returns a list of errors for the most recent function call • mysqli_error() – Returns the last error description for the most recent function call
  • 5. Exception • With PHP 5 came a new object oriented way of dealing with errors. • Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception.
  • 6. Exception $arr = array(23,44,55,77,88,99); try{ if(in_array(4,$arr)){ echo "FOUND"; }else{ throw new exception("4 not found in the array"); } if(is_array($arr)){ echo "TRUE"; }else{ throw new customException("It is not an array"); } } catch(exception $e){ echo "Error occured in the file: ".$e->getFile()." and in line ".$e->getLine()." with a message: ".$e->getMessage(); } catch(customException $e){ echo $e->errorMessage(); }
  • 7. Database • A database is an organized collection of information. Small businesses can use databases in a number of different ways. A database can help you organize information about your customers and clients. A database can contain information about your product inventory. A database can track sales, expenses and other financial information. • In a database an entity type is the equivalent of a table. Each individual record is represented as a row, and each attribute as a column.
  • 8. Hierarchical Database Model • IBM introduced the first generation of database technology, known as hierarchical, when it installed IMS (Information Management System ) in its mainframe computers in the mid-1960s. This technology was upgraded in the mid-1970s to network database technology. Both hierarchical and network databases are often described by the term hierarchical database.
  • 10. Hierarchical Database Model • The structure allows representing information using parent/child relationships: each parent can have many children, but each child has only one parent (also known as a 1-to-many relationship). All attributes of a specific record are listed under an entity type. • Currently the most widely used hierarchical databases are IMS developed by IBM and Windows Registry by Microsoft. • Mother–child relationship: Child may only have one mother but a mother can have multiple children. Mothers and children are tied together by links called "pointers". A mother will have a list of pointers to each of her children.
  • 11. Hierarchical Database Model • "Hierarchical database systems are difficult to use. They require application developers to program navigation through the connected records [...] • "They also require developers to predict all possible access patterns in advance and design the database accordingly. A database access pattern that is not included in the design becomes very difficult and inefficient."
  • 12. Aggregation • Aggregation – The aggregation is an abstraction concept, which is used to build higher-level object (object as a whole) from its components. For example, a computer is built by using various related components.
  • 13. Aggregation • The aggregation abstraction allows the designer to either decompose objects by breaking them into more detailed components or to aggregate objects, grouping them together into higher-level objects. Decomposition is simply the. opposite process to aggregation. Both processes are considered the part of the aggregation abstraction.
  • 14. Generalization • Generalization is another powerful abstraction. Generalization allows entities of different types to be considered as examples of a higher level set. It means that combining different types of entities (or objects) into a higher-level set or in more general entity types is called generalization. – For example, electronic device is a more general entity type of electronic objects like computer, TV set etc.
  • 15. Specialization • Categorizing the entities (or objects) in the set according to their roles in a relationship, is called specialization. Specialization is the process of defining a set of subclasses of an entity. The set of subclasses that form a specialization are defined on the basis of some distinguishing characteristics of the entities in the super-class.
  • 16. Specialization • Clerk, manager, and programmer – super-class 'Employee’ • An entity may have several specializations. – EMPLOYEE • 'Permanent-Employee' • 'Temporary-Employee'
  • 17. Database Normalization • Normalization is the process of efficiently organizing data in a database. • There are two goals of the normalization process: – Eliminating redundant data (for example, storing the same data in more than one table) – Ensuring data dependencies make sense (only storing related data in a table).
  • 18. Database Normalization • First Normal Form (1NF): First normal form (1NF) sets the very basic rules for an organized database: – Eliminate duplicative columns from the same table. – Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).
  • 21. Database Normalization • Second Normal Form (2NF): Second normal form (2NF) further addresses the concept of removing duplicative data: – Meet all the requirements of the first normal form. – Remove subsets of data that apply to multiple rows of a table and place them in separate tables. – Create relationships between these new tables and their predecessors through the use of foreign keys.
  • 24. Database Normalization • Third normal form (3NF) goes one large step further: – Meet all the requirements of the second normal form. – There is no transitive functional dependency
  • 27. Database Normalization • The Boyce-Codd Normal Form, also referred to as the "third and half (3.5) normal form", adds one more requirement: – Meet all the requirements of the third normal form. – Every determinant must be a candidate key.
  • 28. Database Normalization • In order to convert a table to BCNF, we must: 1. Find and remove the overlapping candidate keys. Place the part of the candidate key and the attribute it is functionally dependent on, in a different table. 2. Group the remaining items into a table.
  • 29. • Suppose we have five columns in a table. Primary Key Database Normalization
  • 30. • but column C can determine the value of column B. • In other words, the value of Column B is determined by the Column C then this table can not be in the Boyce - Codd Normal Form. Database Normalization
  • 31. • To convert this table into BCNF, we need to divide into two tables. • The table1 contains the following columns. • where primary key is the combination of the column A and B Database Normalization
  • 32. • And table2 will contain the two columns. • where C will be the primary key. • Thus every table satisfying the 3NF condition cannot be said to be in BCNF normal form but a table in BCNF will always be in 3NF form. Database Normalization
  • 33. • Consider the following non-BCNF table: The candidate keys of the table are: • {Person, Shop Type} • {Person, Nearest Shop} Database Normalization
  • 34. Why it is not BCNF? • The violation of BCNF means that the table is subject to anomalies. For example, Eagle Eye might have its Shop Type changed to "Optometrist" on its "Fuller" record while retaining the Shop Type "Optician" on its "Davidson" record. Database Normalization
  • 35. How to convert itn into BCNF? Database Normalization
  • 36. • After normalization Candidate keys are {person, shop} and{shop},respectively. Database Normalization
  • 37. Database Normalization • Fourth Normal Form (4NF): Finally, fourth normal form (4NF) has one additional requirement: – Meet all the requirements of the third normal form. – A relation is in 4NF if it has no multi-valued dependencies.
  • 40. Relationship • One-to-one relationships: Occur when each entry in the first table has one, and only one, counterpart in the second table. – One-to-one relationships are rarely used because it is often more efficient to simply put all of the information in a single table. • One-to-many relationships: Are the most common type of database relationship. They occur when each record in the first table corresponds to one or more records in the second table but each record in the second table corresponds to only one record in the first table. – For example, the relationship between a Teachers table and a Students table in an elementary school database would likely be a one-to-many relationship, because each student has only one teacher, but each teacher may have multiple students. • Many-to-many relationships: Occur when each record in the first table corresponds to one or more records in the second table and each record in the second table corresponds to one or more records in the first table. – For example, the relationship between a Teachers and a Courses table would likely be many- to-many because each teacher may instruct more than one course and each course may have more than one instructor.