SlideShare a Scribd company logo
1 of 16
SQL Statement Template: A Development
Approach for Database-Driven
Applications
Osama M. Khaled
The American University in Cairo
okhaled@aucegypt.edu
Hoda M. Hosny
The American University in Cairo
hhosny@aucegypt.edu
OUTLINE
 Background
 Domain Analysis
 Roles & Responsibilities
 SQL Statement Template Definition
Language
 Example
BACKGROUND
 Brief History about DB.
 Database role in application
development.
 SQL Statement Externalization.
– Sun DAO Design Pattern
– Business Objects
DOMAIN ANALYSIS
 Defects of bundling SQL statements inside the
application code.
– SQL maintenance requires code recompilation.
– Deviating focus of application developer.
– Readability and understandability decreases.
– DB experts cannot easily read SQL statements inside the
code.
DOMAIN ANALYSIS
Considered Design
Issues
StandardizationMaintainability
ComplexityReusability
ROLES & RESPONSIBILITIES
 Why build SQL statements in design phase.
– DB designer has fresh knowledge about
architecture.
– Helps refining DB design.
– Guarantees consistent SQL statements.
– Implementers will focus more on functional
requirements.
– Speeds up development process.
– DB is a product in itself.
ROLES & RESPONSIBILITIES
Design Phase activities
R
esponsible
for
ROLES & RESPONSIBILITIES
Implementation
R
esponsible
for
Usual
Implementation
Activities
Maintain,
Develop, and
Test SQL
Statement
Templates
ROLES & RESPONSIBILITIES
Affected parties
DB Admin System Administrator
System Support
SQL Statement Templates Files
REVIEW
FOR
OPTIMIZATION
Figure out SQL
problems easily
Resolve bugs
SQL STATEMENT TEMPLATE
DEFINITION LANGUAGE
 SQL Statements Construction
complexity.
Type Example
No replaceable
value
SELECT *
FROM INVOICES
WHERE
INVOICE_TYPE = 1
AND PRICE > 30
Replaceable value
only
SELECT *
FROM INVOICES
WHERE
INVOICE_TYPE = $INVOICE_TYPE$
AND PRICE > $MIN_PRICE$
Replaceable SQL
constructs
SELECT
--$all$ *
--$invoice_number$ inv_no
FROM
INVOICES
--$inv_type$ WHERE INVOICE_TYPE = $INVOICE_TYPE$
--$min_price$ WHERE PRICE > $MIN_PRICE$
SQL STATEMENT TEMPLATE
DEFINITION LANGUAGE
 Describing the language
 Benefits of using this language
– People with database background are more familiar with this
structure.
– Easy to edit with SQL editors.
– Can support easily the third type of the SQL statements
complexities.
– Can be converted easily to XML.
– Definition semantics
– Documentation
– Implementation complexity.
EXAMPLE
SELECT
U.ACTIVITY_NAME AS NUM1,
TO_CHAR(COUNT(*)) AS VALUE
FROM
ACTIVITY U
WHERE
U.EMPLOYEE_ID = $employee_id$
GROUP BY U.ACTIVITY_NAME ORDER BY COUNT(*) DESC
EXAMPLE
SELECT
U.ACTIVITY_NAME AS NUM1,
TO_CHAR(SUM(U.ROUNDED_VOLUME)) AS VALUE
FROM
ACTIVITY U,
GROUPS G,
EMPLOYEE_GROUPS CG
WHERE
U.EMPOLOYEE_ID = $employee_id$ AND
CV.ACTIVITY_TYPE = ’$activity_type$’ AND
CG.EMPLOYEE_KEY = G.EMPLOYEE_KEY AND
CG.GROUPS_KEY = G.GROUPS_KEY AND
U.ACTIVITY_KEY = CG.CACTIVITY_KEY AND
G.EMPLOYEE_KEY = $employee_key$ AND
G.GROUPS_KEY = $group_key$
GROUP BY U.ACTIVITY_NAME ORDER BY
SUM(U.ROUNDED_VOLUME) DESC
EXAMPLE
 --@begin ACTIVITY_ACCESS
 --@group ACTIVITIES
 SELECT
 --$ achievement $ U.ACTIVITY_NAME AS NUM1,
 --$ achievement $ TO_CHAR(COUNT(*)) AS VALUE
 --$cost$ U.ACTIVITY_NAME AS NUM1,
 --$cost$TO_CHAR(SUM(U.RATED_AMOUNT)) AS VALUE
 --$dur$ U.ACTIVITY_NAME AS NUM1,
 --$dur$ TO_CHAR(SUM(U.ROUNDED_VOLUME)) AS VALUE
 FROM ACTIVITY U
 WHERE U.EMPLOYEE_ID = $employee_id$
 --$achievement$ GROUP BY U.ACTIVITY_NAME
 --$achievement$ ORDER BY COUNT(*) DESC
 --$cost$ GROUP BY U.ACTIVITY_NAME
 --$cost$ ORDER BY SUM(U.RATED_AMOUNT) DESC
 --$dur$ GROUP BY U.ACTIVITY_NAME
 --$dur$ ORDER BY SUM(U.ROUNDED_VOLUME) DESC
 --@end ACTIVITY_ACCESS
EXAMPLE
 SQLBlock sqlBlock = SQLIndexer().
 getSQL("ACTIVITY_ACCESS");
 // enable where keyword
 sqlBlock.setTagValue("employee_id",
employee_id);
 // report_type is acheivement, cost, or dur
 sqlBlock.clearCommentTag(report_type);
 Vector result =
select(sqlBlock.getRuntimeSql());
QUESTIONS

More Related Content

Similar to SQL Statement Template

Similar to SQL Statement Template (20)

SQL
SQLSQL
SQL
 
SQL
SQL SQL
SQL
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
ashok3.4 yrs resume
ashok3.4 yrs resumeashok3.4 yrs resume
ashok3.4 yrs resume
 
My Resume
My ResumeMy Resume
My Resume
 
DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3
 
Ponmagal resumedeveloper
Ponmagal resumedeveloperPonmagal resumedeveloper
Ponmagal resumedeveloper
 
Sql and its functions
Sql and its functionsSql and its functions
Sql and its functions
 
sudarsan resume - updated
sudarsan resume - updatedsudarsan resume - updated
sudarsan resume - updated
 
Database Developer_Profile
Database Developer_ProfileDatabase Developer_Profile
Database Developer_Profile
 
Kanakaraj_Periasamy
Kanakaraj_PeriasamyKanakaraj_Periasamy
Kanakaraj_Periasamy
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql server
 
Krishnan SQL Developer
Krishnan SQL DeveloperKrishnan SQL Developer
Krishnan SQL Developer
 
ananth_resume
ananth_resumeananth_resume
ananth_resume
 
Nikhil (2)
Nikhil (2)Nikhil (2)
Nikhil (2)
 
shibindas_Plsql2year
shibindas_Plsql2yearshibindas_Plsql2year
shibindas_Plsql2year
 
Oodb
OodbOodb
Oodb
 
Ponmagal resumedeveloper
Ponmagal resumedeveloperPonmagal resumedeveloper
Ponmagal resumedeveloper
 
Kavindra sahu B_tech_computerscience_oraclesoa_osb_2.7yearsexp
Kavindra sahu B_tech_computerscience_oraclesoa_osb_2.7yearsexpKavindra sahu B_tech_computerscience_oraclesoa_osb_2.7yearsexp
Kavindra sahu B_tech_computerscience_oraclesoa_osb_2.7yearsexp
 

More from Osama M. Khaled

A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...
A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...
A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...Osama M. Khaled
 
A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...
A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...
A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...Osama M. Khaled
 
Static Enabler: A Response Enhancer for Dynamic Web Applications
Static Enabler: A Response Enhancer for Dynamic Web ApplicationsStatic Enabler: A Response Enhancer for Dynamic Web Applications
Static Enabler: A Response Enhancer for Dynamic Web ApplicationsOsama M. Khaled
 
A Survey of Building Robust Business Models in Pervasive Computing
A Survey of Building Robust Business Models in Pervasive ComputingA Survey of Building Robust Business Models in Pervasive Computing
A Survey of Building Robust Business Models in Pervasive ComputingOsama M. Khaled
 
Improving our Approach Towards Capturing Value in Requirements
Improving our Approach Towards Capturing Value in RequirementsImproving our Approach Towards Capturing Value in Requirements
Improving our Approach Towards Capturing Value in RequirementsOsama M. Khaled
 
Pervasive Computing Reference Architecture from a Software Engineering Perspe...
Pervasive Computing Reference Architecture from a Software Engineering Perspe...Pervasive Computing Reference Architecture from a Software Engineering Perspe...
Pervasive Computing Reference Architecture from a Software Engineering Perspe...Osama M. Khaled
 
Internet of Things (IoT) from a business Perspective
Internet of Things (IoT) from a business PerspectiveInternet of Things (IoT) from a business Perspective
Internet of Things (IoT) from a business PerspectiveOsama M. Khaled
 

More from Osama M. Khaled (8)

A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...
A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...
A SIMULATION APPROACH TO PREDICATE THE RELIABILITY OF A PERVASIVE SOFTWARE SY...
 
A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...
A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...
A Statistical Approach to Resolve Conflicting Requirements in Pervasive Compu...
 
Digital Cash Overview
Digital Cash OverviewDigital Cash Overview
Digital Cash Overview
 
Static Enabler: A Response Enhancer for Dynamic Web Applications
Static Enabler: A Response Enhancer for Dynamic Web ApplicationsStatic Enabler: A Response Enhancer for Dynamic Web Applications
Static Enabler: A Response Enhancer for Dynamic Web Applications
 
A Survey of Building Robust Business Models in Pervasive Computing
A Survey of Building Robust Business Models in Pervasive ComputingA Survey of Building Robust Business Models in Pervasive Computing
A Survey of Building Robust Business Models in Pervasive Computing
 
Improving our Approach Towards Capturing Value in Requirements
Improving our Approach Towards Capturing Value in RequirementsImproving our Approach Towards Capturing Value in Requirements
Improving our Approach Towards Capturing Value in Requirements
 
Pervasive Computing Reference Architecture from a Software Engineering Perspe...
Pervasive Computing Reference Architecture from a Software Engineering Perspe...Pervasive Computing Reference Architecture from a Software Engineering Perspe...
Pervasive Computing Reference Architecture from a Software Engineering Perspe...
 
Internet of Things (IoT) from a business Perspective
Internet of Things (IoT) from a business PerspectiveInternet of Things (IoT) from a business Perspective
Internet of Things (IoT) from a business Perspective
 

Recently uploaded

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

SQL Statement Template

  • 1. SQL Statement Template: A Development Approach for Database-Driven Applications Osama M. Khaled The American University in Cairo okhaled@aucegypt.edu Hoda M. Hosny The American University in Cairo hhosny@aucegypt.edu
  • 2. OUTLINE  Background  Domain Analysis  Roles & Responsibilities  SQL Statement Template Definition Language  Example
  • 3. BACKGROUND  Brief History about DB.  Database role in application development.  SQL Statement Externalization. – Sun DAO Design Pattern – Business Objects
  • 4. DOMAIN ANALYSIS  Defects of bundling SQL statements inside the application code. – SQL maintenance requires code recompilation. – Deviating focus of application developer. – Readability and understandability decreases. – DB experts cannot easily read SQL statements inside the code.
  • 6. ROLES & RESPONSIBILITIES  Why build SQL statements in design phase. – DB designer has fresh knowledge about architecture. – Helps refining DB design. – Guarantees consistent SQL statements. – Implementers will focus more on functional requirements. – Speeds up development process. – DB is a product in itself.
  • 7. ROLES & RESPONSIBILITIES Design Phase activities R esponsible for
  • 9. ROLES & RESPONSIBILITIES Affected parties DB Admin System Administrator System Support SQL Statement Templates Files REVIEW FOR OPTIMIZATION Figure out SQL problems easily Resolve bugs
  • 10. SQL STATEMENT TEMPLATE DEFINITION LANGUAGE  SQL Statements Construction complexity. Type Example No replaceable value SELECT * FROM INVOICES WHERE INVOICE_TYPE = 1 AND PRICE > 30 Replaceable value only SELECT * FROM INVOICES WHERE INVOICE_TYPE = $INVOICE_TYPE$ AND PRICE > $MIN_PRICE$ Replaceable SQL constructs SELECT --$all$ * --$invoice_number$ inv_no FROM INVOICES --$inv_type$ WHERE INVOICE_TYPE = $INVOICE_TYPE$ --$min_price$ WHERE PRICE > $MIN_PRICE$
  • 11. SQL STATEMENT TEMPLATE DEFINITION LANGUAGE  Describing the language  Benefits of using this language – People with database background are more familiar with this structure. – Easy to edit with SQL editors. – Can support easily the third type of the SQL statements complexities. – Can be converted easily to XML. – Definition semantics – Documentation – Implementation complexity.
  • 12. EXAMPLE SELECT U.ACTIVITY_NAME AS NUM1, TO_CHAR(COUNT(*)) AS VALUE FROM ACTIVITY U WHERE U.EMPLOYEE_ID = $employee_id$ GROUP BY U.ACTIVITY_NAME ORDER BY COUNT(*) DESC
  • 13. EXAMPLE SELECT U.ACTIVITY_NAME AS NUM1, TO_CHAR(SUM(U.ROUNDED_VOLUME)) AS VALUE FROM ACTIVITY U, GROUPS G, EMPLOYEE_GROUPS CG WHERE U.EMPOLOYEE_ID = $employee_id$ AND CV.ACTIVITY_TYPE = ’$activity_type$’ AND CG.EMPLOYEE_KEY = G.EMPLOYEE_KEY AND CG.GROUPS_KEY = G.GROUPS_KEY AND U.ACTIVITY_KEY = CG.CACTIVITY_KEY AND G.EMPLOYEE_KEY = $employee_key$ AND G.GROUPS_KEY = $group_key$ GROUP BY U.ACTIVITY_NAME ORDER BY SUM(U.ROUNDED_VOLUME) DESC
  • 14. EXAMPLE  --@begin ACTIVITY_ACCESS  --@group ACTIVITIES  SELECT  --$ achievement $ U.ACTIVITY_NAME AS NUM1,  --$ achievement $ TO_CHAR(COUNT(*)) AS VALUE  --$cost$ U.ACTIVITY_NAME AS NUM1,  --$cost$TO_CHAR(SUM(U.RATED_AMOUNT)) AS VALUE  --$dur$ U.ACTIVITY_NAME AS NUM1,  --$dur$ TO_CHAR(SUM(U.ROUNDED_VOLUME)) AS VALUE  FROM ACTIVITY U  WHERE U.EMPLOYEE_ID = $employee_id$  --$achievement$ GROUP BY U.ACTIVITY_NAME  --$achievement$ ORDER BY COUNT(*) DESC  --$cost$ GROUP BY U.ACTIVITY_NAME  --$cost$ ORDER BY SUM(U.RATED_AMOUNT) DESC  --$dur$ GROUP BY U.ACTIVITY_NAME  --$dur$ ORDER BY SUM(U.ROUNDED_VOLUME) DESC  --@end ACTIVITY_ACCESS
  • 15. EXAMPLE  SQLBlock sqlBlock = SQLIndexer().  getSQL("ACTIVITY_ACCESS");  // enable where keyword  sqlBlock.setTagValue("employee_id", employee_id);  // report_type is acheivement, cost, or dur  sqlBlock.clearCommentTag(report_type);  Vector result = select(sqlBlock.getRuntimeSql());

Editor's Notes

  1.          Standardization: Separating SQL statements from code must maintain the standard SQL scripting to facilitate reading, debugging, and modifying them for the DB experts.          Maintainability: The SQL Statement Template interface between the application and the external files must be very clear at the design phase. Although, it may be changed in the development phase.          Complexity: The solution should organize the SQL statements and group them in a professional way. It must also provide a technique to handle the IF conditions by which different blocks of the SQL statements may be grouped together inside the code.          Reusability: The SQL Statement Templates should be available for other applications that may need to access the same Database although they may have different functionality.
  2. . Show the benefits of building the SQL statements in the design phase. . Explain the activity diagram of the design phase + roles and responsibilities . Explain the activities of the implementation phase . Show how other role players could be affected directly by using SQL statement templates. (DB administrators, system administrators, system support)