SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
Business Rules and How they are
applied in Databases
Tharindu Weerasinghe
www.tharinduweerasinghe.com
Business rules are set of approved guideliness or framework within an
organization. They simplify daily operations of any organization. From
an engineering perspective, a business rule is a set of of reusable
business logic.
Example Business Rules:
➔
Hierarchy of decision making and approving company invoices.
➔
Formula or scenarios in deciding Key Performance Indicators.
➔
Company policies in taking medical leaves
Business Rules
A formula based rules:
➔
Define and preserve some formulas (such as average, sum, mean,
median etc)
➔
Can use any data processing work sheet application in order to operate
➔
e.g. OT calculation formulas, Annual Leave Allocations, Bonus calculations
A decision table based rules:
➔
Non software developers can easily present their ideas via this
➔
If-then logic is used
➔
Use columns as the conditions and rows specify the appropriate outcomes. e.g.
Invoice Approvals, Application Acceptance Criteria, Personal Loan Eligibility
checks.
Business Rules - Types
In a cooperate organization:
➔
Every employee should be present by 9am and work 9 hours per day.
➔
Every employee must under do a CPD course in-order to get an increment.
➔
The company will offer a bonus of half a salary in April.
In Academia: (Say in a University):
➔
Every student must have 80% attendance in-order to sit for an exam.
➔
A student has to obtain 50 out of 100 in-order to pass a subject.
➔
The maximum no. of lower grade subjects that a student can have is 3.
Business Rules – Examples
NOUN –VERB – NOUN is a common structure for business rule
TERM – FACT – TERM is the formal semantic for this type of
business rule template
e.g.
Invoice ID should contain 10 characters only. It should
clearly show the the branch ID and invoice number.
Price must be included in all product labels.
Business Rules – How they are
written or presented
Business rules will become constraints at the Database
Level
e.g. Each customer invoice should have unique
identifying number:
INV_0001
INV_CMB_0001
Implementation of Business Rules in
DBs
So what are contraints?
The word gives you the meaning – Limitations!
What do we limit?
The behavior/process/mechanism/pattern of an organization
If that organization's process or system is automated then the
mentioned business rules become contraints in the DB level!
Implementation of Business Rules in DBs
Implementation of Business Rules in DBs
Constraints let you define the way the Database Engine
automatically enforces the integrity of a Database.
Integrity of a DB is about maintaining a unique structure! - Will
be discussed in a later slide.
Constraints define rules which are enforced on the values in the columns.
NOT NULL specifies that the column does not accept NULL values
A check constraint allows you to specify a condition
A length of the value of a column describes the maximum limit of the
value you can have there.
Implementation of Business Rules in DBs
The following MySQL statement illustrates certain constraints.
DROP TABLE IF EXISTS `employees`;
/*!40101 SET @saved_cs_client     = 
@@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `employees` (
  `empid` int(10) unsigned NOT NULL,
  `name` varchar(300) NOT NULL,
  `homeaddress` text NOT NULL,
  `email` varchar(200) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `salary` varchar(20) NOT NULL,
  `joineddate` varchar(25) NOT NULL,
  `lastincrementdate` varchar(25) NOT NULL,
  `dateofbirth` varchar(25) NOT NULL,
  `designation` varchar(30) NOT NULL,
  `leaves` int(11) DEFAULT NULL,
  `resigneddate` varchar(25) DEFAULT NULL,
  `expertise` varchar(75) DEFAULT NULL,
  `nic` varchar(10) NOT NULL,
  PRIMARY KEY (`empid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
Implementation of Business Rules in DBs
The following MySQL statement illustrates certain constraints.
DROP TABLE IF EXISTS `projects`;
/*!40101 SET @saved_cs_client     = 
@@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `projects` (
  `projid` varchar(20) NOT NULL,
  `projname` varchar(30) NOT NULL,
  `starteddate` varchar(25) NOT NULL,
  `currentstatus` varchar(25) NOT NULL,
  `projinfo` varchar(300) DEFAULT NULL,
  PRIMARY KEY (`projid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = 
@saved_cs_client */;
Implementation of Business Rules in DBs
The following MySQL statement illustrates certain constraints.
DROP TABLE IF EXISTS `inventory`;
/*!40101 SET @saved_cs_client     = 
@@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inventory` (
  `seqid` int(20) NOT NULL AUTO_INCREMENT,
  `itemtype` varchar(300) NOT NULL,
  `itemname` text NOT NULL,
  `itemid` varchar(20) NOT NULL,
  `usedby` int(10) DEFAULT NULL,
  PRIMARY KEY (`seqid`),
  UNIQUE KEY `itemid` (`itemid`)
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT 
CHARSET=latin1;
/*!40101 SET character_set_client = 
@saved_cs_client */;
Database Integrity – 3 types
Entity Integrity: This brings up the concept of primary keys. The rule says
that every table must have its own primary key and that each has to be
unique and not null.
Referential Integrity: This brings up the concept of foreign keys. The rule
says that the foreign key value can be in two states. The first state is that the
foreign key value would refer to a primary key value of another table, or it
can be null. Being null means that there are no relationships, or that the
relationship is unknown.
Domain Integrity: This brings up the phenomena that all columns in a
relational database are in a defined domain.
Integrity of a DB is about maintaining its own unique structure according to the
business rules! The way it is, the way should be! - This is Tharindu's definition
Gratitude
References:
https://www.laserfiche.com/ecmblog/what-are-business-rules/
https://www.techopedia.com/definition/811/data-integrity-databases
Previous Year ICTST40704 (UVT – Sri Lanka) lecture notes of Mr. Sanjeeva Perera

Weitere ähnliche Inhalte

Was ist angesagt?

Codd's rules
Codd's rulesCodd's rules
Codd's rules
Mohd Arif
 
FP304 DATABASE SYSTEM PAPER FINAL EXAM AGAIN
FP304 DATABASE SYSTEM  PAPER FINAL EXAM AGAINFP304 DATABASE SYSTEM  PAPER FINAL EXAM AGAIN
FP304 DATABASE SYSTEM PAPER FINAL EXAM AGAIN
Syahriha Ruslan
 
Software requirements specification
Software  requirements specificationSoftware  requirements specification
Software requirements specification
Krishnasai Gudavalli
 
Physical database design(database)
Physical database design(database)Physical database design(database)
Physical database design(database)
welcometofacebook
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
Piyush Rochwani
 

Was ist angesagt? (20)

Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3
 
Data Representation of Strings
Data Representation of StringsData Representation of Strings
Data Representation of Strings
 
Codd's rules
Codd's rulesCodd's rules
Codd's rules
 
Data models
Data modelsData models
Data models
 
FP304 DATABASE SYSTEM PAPER FINAL EXAM AGAIN
FP304 DATABASE SYSTEM  PAPER FINAL EXAM AGAINFP304 DATABASE SYSTEM  PAPER FINAL EXAM AGAIN
FP304 DATABASE SYSTEM PAPER FINAL EXAM AGAIN
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
Chapter13 designing forms and reports
Chapter13 designing forms and reportsChapter13 designing forms and reports
Chapter13 designing forms and reports
 
Software requirements specification
Software  requirements specificationSoftware  requirements specification
Software requirements specification
 
System Analysis And Design
System Analysis And DesignSystem Analysis And Design
System Analysis And Design
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)
 
Ordbms
OrdbmsOrdbms
Ordbms
 
Database File operation
Database File operationDatabase File operation
Database File operation
 
Anomalies in database
Anomalies in databaseAnomalies in database
Anomalies in database
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Normalization of database tables
Normalization of database tablesNormalization of database tables
Normalization of database tables
 
Learn Normalization in simple language
Learn Normalization in simple languageLearn Normalization in simple language
Learn Normalization in simple language
 
Physical database design(database)
Physical database design(database)Physical database design(database)
Physical database design(database)
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Advantages and disadvantages of er model in DBMS. Types of database models ..
Advantages and disadvantages of er model in DBMS. Types of database models ..Advantages and disadvantages of er model in DBMS. Types of database models ..
Advantages and disadvantages of er model in DBMS. Types of database models ..
 

Ähnlich wie Business Rules in Databases

Performance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and ApexPerformance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and Apex
Salesforce Developers
 
Biz Talk Demo slideshare
Biz Talk Demo slideshareBiz Talk Demo slideshare
Biz Talk Demo slideshare
erios
 
AimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docxAimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docx
simonlbentley59018
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
Chris Seebacher
 
Requirement matrix concepts & implementation
Requirement matrix   concepts & implementationRequirement matrix   concepts & implementation
Requirement matrix concepts & implementation
stariveer
 
Sample_Data_and_Data_Modules
Sample_Data_and_Data_ModulesSample_Data_and_Data_Modules
Sample_Data_and_Data_Modules
Michael Cook
 

Ähnlich wie Business Rules in Databases (20)

Performance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and ApexPerformance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and Apex
 
Df12 Performance Tuning
Df12 Performance TuningDf12 Performance Tuning
Df12 Performance Tuning
 
130214 wei wu - extracting business rules and removing duplication with iris
130214   wei wu - extracting business rules and removing duplication with iris130214   wei wu - extracting business rules and removing duplication with iris
130214 wei wu - extracting business rules and removing duplication with iris
 
Business rules
Business rulesBusiness rules
Business rules
 
Requirements Gathering Best Practice Pack
Requirements Gathering Best Practice PackRequirements Gathering Best Practice Pack
Requirements Gathering Best Practice Pack
 
James Colby Maddox Business Intellignece and Computer Science Portfolio
James Colby Maddox Business Intellignece and Computer Science PortfolioJames Colby Maddox Business Intellignece and Computer Science Portfolio
James Colby Maddox Business Intellignece and Computer Science Portfolio
 
Top Seven Steps for Optimizing Cross-Validation Rules in General Ledger
Top Seven Steps for Optimizing Cross-Validation Rules in General LedgerTop Seven Steps for Optimizing Cross-Validation Rules in General Ledger
Top Seven Steps for Optimizing Cross-Validation Rules in General Ledger
 
Biz Talk Demo slideshare
Biz Talk Demo slideshareBiz Talk Demo slideshare
Biz Talk Demo slideshare
 
AimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docxAimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docx
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Requirement matrix concepts & implementation
Requirement matrix   concepts & implementationRequirement matrix   concepts & implementation
Requirement matrix concepts & implementation
 
Business Improvement
Business ImprovementBusiness Improvement
Business Improvement
 
Database Modeling presentation
Database Modeling  presentationDatabase Modeling  presentation
Database Modeling presentation
 
A G S006 Little 091807
A G S006  Little 091807A G S006  Little 091807
A G S006 Little 091807
 
Sample_Data_and_Data_Modules
Sample_Data_and_Data_ModulesSample_Data_and_Data_Modules
Sample_Data_and_Data_Modules
 
Building an Enterprise Metadata Repository
Building an Enterprise Metadata RepositoryBuilding an Enterprise Metadata Repository
Building an Enterprise Metadata Repository
 
EBS Answers Webinar Series - Tricks for Optimizing Cross-Validation Rules in ...
EBS Answers Webinar Series - Tricks for Optimizing Cross-Validation Rules in ...EBS Answers Webinar Series - Tricks for Optimizing Cross-Validation Rules in ...
EBS Answers Webinar Series - Tricks for Optimizing Cross-Validation Rules in ...
 
Mi0034
Mi0034Mi0034
Mi0034
 
Essbase Calculations: Elements of Style
Essbase Calculations: Elements of StyleEssbase Calculations: Elements of Style
Essbase Calculations: Elements of Style
 
Om0011 enterprises resource planning 2
Om0011  enterprises resource planning 2Om0011  enterprises resource planning 2
Om0011 enterprises resource planning 2
 

Mehr von Tharindu Weerasinghe

Mehr von Tharindu Weerasinghe (20)

C Propgramming.pdf
C Propgramming.pdfC Propgramming.pdf
C Propgramming.pdf
 
Basics of Computer Networks in Sinhala
Basics of Computer Networks in SinhalaBasics of Computer Networks in Sinhala
Basics of Computer Networks in Sinhala
 
Data Structures & Algorithms in Sinhala
Data Structures & Algorithms in SinhalaData Structures & Algorithms in Sinhala
Data Structures & Algorithms in Sinhala
 
Object Oriended Programming in Sinhala
Object Oriended Programming in Sinhala Object Oriended Programming in Sinhala
Object Oriended Programming in Sinhala
 
Tips For A Better Undergraduate Research
Tips For A Better Undergraduate ResearchTips For A Better Undergraduate Research
Tips For A Better Undergraduate Research
 
Basics of Block Chain
Basics of Block ChainBasics of Block Chain
Basics of Block Chain
 
Basics of IoT
Basics of IoTBasics of IoT
Basics of IoT
 
REST API Basics
REST API BasicsREST API Basics
REST API Basics
 
Cloud Conputing Basics and some Related Research Topics
Cloud Conputing Basics and some Related Research TopicsCloud Conputing Basics and some Related Research Topics
Cloud Conputing Basics and some Related Research Topics
 
Basic Concepts and Trends in Emerging Technologies
Basic Concepts and Trends in Emerging TechnologiesBasic Concepts and Trends in Emerging Technologies
Basic Concepts and Trends in Emerging Technologies
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
 
Introduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and ToolsIntroduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and Tools
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
 
Agile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingAgile Languages for Rapid Prototyping
Agile Languages for Rapid Prototyping
 
Things to ponder before you start building [cooperate] software
Things to ponder before you start building [cooperate] softwareThings to ponder before you start building [cooperate] software
Things to ponder before you start building [cooperate] software
 
How to make screens and the internet safe for Children
How to make screens and the internet safe for Children How to make screens and the internet safe for Children
How to make screens and the internet safe for Children
 
Different Concepts on Databases
Different Concepts on DatabasesDifferent Concepts on Databases
Different Concepts on Databases
 
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Sri Lankan IT ProfessionalsA Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
 
A Survey Study on Higher Education Trends among Information Technology Prof...
A Survey Study  on  Higher Education Trends among Information Technology Prof...A Survey Study  on  Higher Education Trends among Information Technology Prof...
A Survey Study on Higher Education Trends among Information Technology Prof...
 
Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry  Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry
 

Kürzlich hochgeladen

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Kürzlich hochgeladen (20)

WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 

Business Rules in Databases

  • 1. Business Rules and How they are applied in Databases Tharindu Weerasinghe www.tharinduweerasinghe.com
  • 2. Business rules are set of approved guideliness or framework within an organization. They simplify daily operations of any organization. From an engineering perspective, a business rule is a set of of reusable business logic. Example Business Rules: ➔ Hierarchy of decision making and approving company invoices. ➔ Formula or scenarios in deciding Key Performance Indicators. ➔ Company policies in taking medical leaves Business Rules
  • 3. A formula based rules: ➔ Define and preserve some formulas (such as average, sum, mean, median etc) ➔ Can use any data processing work sheet application in order to operate ➔ e.g. OT calculation formulas, Annual Leave Allocations, Bonus calculations A decision table based rules: ➔ Non software developers can easily present their ideas via this ➔ If-then logic is used ➔ Use columns as the conditions and rows specify the appropriate outcomes. e.g. Invoice Approvals, Application Acceptance Criteria, Personal Loan Eligibility checks. Business Rules - Types
  • 4. In a cooperate organization: ➔ Every employee should be present by 9am and work 9 hours per day. ➔ Every employee must under do a CPD course in-order to get an increment. ➔ The company will offer a bonus of half a salary in April. In Academia: (Say in a University): ➔ Every student must have 80% attendance in-order to sit for an exam. ➔ A student has to obtain 50 out of 100 in-order to pass a subject. ➔ The maximum no. of lower grade subjects that a student can have is 3. Business Rules – Examples
  • 5. NOUN –VERB – NOUN is a common structure for business rule TERM – FACT – TERM is the formal semantic for this type of business rule template e.g. Invoice ID should contain 10 characters only. It should clearly show the the branch ID and invoice number. Price must be included in all product labels. Business Rules – How they are written or presented
  • 6. Business rules will become constraints at the Database Level e.g. Each customer invoice should have unique identifying number: INV_0001 INV_CMB_0001 Implementation of Business Rules in DBs
  • 7. So what are contraints? The word gives you the meaning – Limitations! What do we limit? The behavior/process/mechanism/pattern of an organization If that organization's process or system is automated then the mentioned business rules become contraints in the DB level! Implementation of Business Rules in DBs
  • 8. Implementation of Business Rules in DBs Constraints let you define the way the Database Engine automatically enforces the integrity of a Database. Integrity of a DB is about maintaining a unique structure! - Will be discussed in a later slide. Constraints define rules which are enforced on the values in the columns. NOT NULL specifies that the column does not accept NULL values A check constraint allows you to specify a condition A length of the value of a column describes the maximum limit of the value you can have there.
  • 9. Implementation of Business Rules in DBs The following MySQL statement illustrates certain constraints. DROP TABLE IF EXISTS `employees`; /*!40101 SET @saved_cs_client     =  @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `employees` (   `empid` int(10) unsigned NOT NULL,   `name` varchar(300) NOT NULL,   `homeaddress` text NOT NULL,   `email` varchar(200) NOT NULL,   `phone` varchar(20) NOT NULL,   `salary` varchar(20) NOT NULL,   `joineddate` varchar(25) NOT NULL,   `lastincrementdate` varchar(25) NOT NULL,   `dateofbirth` varchar(25) NOT NULL,   `designation` varchar(30) NOT NULL,   `leaves` int(11) DEFAULT NULL,   `resigneddate` varchar(25) DEFAULT NULL,   `expertise` varchar(75) DEFAULT NULL,   `nic` varchar(10) NOT NULL,   PRIMARY KEY (`empid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */;
  • 10. Implementation of Business Rules in DBs The following MySQL statement illustrates certain constraints. DROP TABLE IF EXISTS `projects`; /*!40101 SET @saved_cs_client     =  @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `projects` (   `projid` varchar(20) NOT NULL,   `projname` varchar(30) NOT NULL,   `starteddate` varchar(25) NOT NULL,   `currentstatus` varchar(25) NOT NULL,   `projinfo` varchar(300) DEFAULT NULL,   PRIMARY KEY (`projid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client =  @saved_cs_client */;
  • 11. Implementation of Business Rules in DBs The following MySQL statement illustrates certain constraints. DROP TABLE IF EXISTS `inventory`; /*!40101 SET @saved_cs_client     =  @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inventory` (   `seqid` int(20) NOT NULL AUTO_INCREMENT,   `itemtype` varchar(300) NOT NULL,   `itemname` text NOT NULL,   `itemid` varchar(20) NOT NULL,   `usedby` int(10) DEFAULT NULL,   PRIMARY KEY (`seqid`),   UNIQUE KEY `itemid` (`itemid`) ) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT  CHARSET=latin1; /*!40101 SET character_set_client =  @saved_cs_client */;
  • 12. Database Integrity – 3 types Entity Integrity: This brings up the concept of primary keys. The rule says that every table must have its own primary key and that each has to be unique and not null. Referential Integrity: This brings up the concept of foreign keys. The rule says that the foreign key value can be in two states. The first state is that the foreign key value would refer to a primary key value of another table, or it can be null. Being null means that there are no relationships, or that the relationship is unknown. Domain Integrity: This brings up the phenomena that all columns in a relational database are in a defined domain. Integrity of a DB is about maintaining its own unique structure according to the business rules! The way it is, the way should be! - This is Tharindu's definition