SlideShare a Scribd company logo
1 of 54
Managing the Earthquake:
Surviving Major Database Architecture
Changes
(rev.2022)
Michael Rosenblum
www.dulcian.com
2 of 54
Who Am I? – “Misha”
Oracle ACE
Co-author of 3 books
 PL/SQL for Dummies
 Expert PL/SQL Practices
 Oracle PL/SQL Performance Tuning Tips & Techniques
Known for:
 SQL and PL/SQL tuning
 Complex functionality
 Code generators
 Repository-based development
3 of 54
Background (1)
Year 2011
I didn’t have any gray hair.
I had just published my second book.
I thought that I knew everything about database development.
I had been building IT systems for a WHOLE DECADE!
4 of 54
Background (2)
I successfully gave the following presentation:
5 of 54
Background (3)
Year 2022:
I am slowly starting to resemble Santa Claus.
I’ve become tired of publishing.
I recognize that knowing everything is impossible.
I have been building and maintaining IT systems at the same
company for TWO DECADES! 
6 of 54
Background (4)
Point of view:
Keeping systems alive for years teaches you a lot about good
vs. bad architectures.
 … and you get a chance to learn from your own mistakes.
You recognize strategic vs. tactical trade-offs.
 … and you get a chance to learn from your management mistakes.
7 of 54
So…
“Managing the Earthquake” rev.2022:
1. Why bother?
2. Trends
3. Best practices
8 of 54
1. Why Bother?!
9 of 54
Does anybody care?
Perfectly valid question:
Agile development is iterative by its nature.
DevOps is focused on continuous delivery 
 You (theoretically) should be able to rapidly adjust the system to
changes.
All startups want to deliver something new faster than anybody
else (i.e. what matters is V1)
10 of 54
Yes, we do!
 Reasons:
Changes are inevitable
 … so, there will be V2,V3 etc.
Patience is a very rare virtue
 … i.e. you will be constantly running against the clock.
Constraints:
Agile development works only sometimes
 … and when it doesn’t work – the whole process is SLOW!
Efficient DevOps is hard to set up and is often limited in scope
 … because data/data storage is the most critical IT asset.
11 of 54
Reality Check
Time is limited
… otherwise you could just build something new every time.
Money is limited
… i.e. throwing more developers/hardware may help, but only
up to a point.
Predictability is limited
… i.e. you cannot protect yourself against “unknown
unknowns.”
12 of 54
2. Trends
13 of 54
Known Unknowns (1)
We ARE going to “the cloud”
… but there are different “flavors” of cloud implementations
(each with its own limitations/features).
 Architectural ramifications:
Different pricing mechanisms may require different
optimization patterns.
Platform-dependent features have to be vetted very carefully.
14 of 54
Example
 Case:
 During final tests, clients were contemplating Amazon RDS as one
of the hosting options.
Impact:
 At that time, RDS did not support Java within the database.
Solution:
 Rewrite of Base64 encoding/decoding to become purely PL/SQL-
based.
Lesson learned:
 Hosting decisions must be explicitly spelled out beforehand!
15 of 54
Known Unknowns (2)
We ARE working with unstructured/semi-structured data
… but that data could be stored in a number of different forms
(within an Oracle DB/separate noSQL implementation)
Architectural ramifications:
Cheap short-term solutions may not scale.
Semi-structured data could mutate.
16 of 54
Example
Case:
 External provider suddenly decided to change communication
mechanism from XML to JSON and warned about potential internal
JSON changes in the future.
Impact:
 Historical reporting became complicated.
Solution:
 To protect existing functionality, extract key data elements out of
XML/JSON into a relational table.
Lesson learned:
 If you have an API-driven system, it is better to have a platform-
independent isolation layer in-between.
17 of 54
Known Unknowns (3)
You WILL be releasing the next version (sooner than you
expect)
… and somebody will have to do it.
Architectural ramifications:
Last 5% of requirements often take the most time.
Every system architect should have a clear path between IOC
and FOC.
Not delivering that last 5% could be a major contract breach.
18 of 54
Example
Case:
 One consulting company was “dragging their feet” for a couple of
years by partially implementing requirements. The company was
fired and eventually sued by the client.
Research:
 I was involved as an expert and was able to prove that the provided
architecture was not capable of doing what was promised.
Impact:
 The consulting company had a huge fine imposed and had to return
all of the money earned under that contract.
Lesson learned:
 Cover-ups have a tendency to blow up!
19 of 54
3. Best Practices
20 of 54
Personal Bragging - Story #1
United States Air Force Recruiting system
Initially built in 2003 – contract was just extended for another 5
years
Survived:
 Shift from single component to multi-component structure
 Absorption of various smaller Air Force services
 Several internal Air Force hierarchy reorganizations
 Transformation from app-based to browser-based
 Architectural shifts in recruitment form maintenance
 Migration from “on-premises” to “cloud”
21 of 54
Personal Bragging - Story #2
New York State Office of Alcohol and Substance Abuse
Services (NYS OASAS)
Initially built before I joined Dulcian  - still currently
operational
Survived:
 Rewrite from Oracle Forms to 100% web-based solution without
functionality loss (FormSpider©!)
 Significant expansion of scope and number of users
 Multiple internal architectural shifts
22 of 54
3.1. Data Models
23 of 54
Why Data Modeling Matters
 Database structure is the least agile part of the system:
It has to be flexible enough to absorb expected “small” changes.
It has to be generic enough to simplify “mid-level” changes.
The database is the most critical part of the whole system:
It has to be understandable enough to prevent inadvertent data
corruption.
It has to perform well enough for the expected workload.
24 of 54
“Smart Columns” vs. Attributes
Column
 Represents a single logical attribute
 Does not make sense if split
“Smart” column
 Has internal structure
 May even change meaning depending upon the data
Opinion:
 Major source of problems!
 During system migration, I NEVER encountered “smart columns” without some kind
of issues.
 Avoid them if you can!
25 of 54
Examples of “Smart” Columns
Organization rollup
 Pipe-delimited combination of Region/State/City/Zip
 Long-term project impact:
 Adding extra level to rollup became extremely challenging.
 Search was very expensive.
Answers on questionnaires:
 Single text line where number of characters = number of questions:
“YYYNNNNYYNY”
 Long-term project impact
 Developer’s mistake during one release caused data corruption that was
detected only after some time  major data recovery project
26 of 54
If it is more than ONE – is it MANY?
Correct model:
Proper Generalization
Org Ship
OrgRole
- Role_CD
0..*
1
0..1 0..*
manage
maintain
Org Ship
0..1
0..* 0..*
1
0..*
repair
0..1
27 of 54
OVER-Generalization
Reasons for generic solutions:
Changes are costly.
We feel “protected” against the future.
Generic models are “cool” (especially now with the Big Data
movement).
BUT
Generic solutions often mask an incomplete understanding of
the subject area.
Generic solutions in one area may cause major issues in others.
28 of 54
Example of Over-Generalization
Object AttribValue
- Name
- Value_NR
- Value_DT
- Value_TX
Assoc
0..*
0..*
0..*
1
1 1
29 of 54
Over-Generalization Problems
Data entry:
Uses a lot of operations to retrieve a single object
Data quality is hard to enforce.
Data retrieval
Indexes are useless.
CBO goes crazy.
Performance is sporadic and does not follow any meaningful
logic.
Functional complex reporting is impossible.
30 of 54
Over-Generalization Potential
There are cases when key-value stores are perfect
(NoSQL environments).
BUT they should not be mixed with:
OLTP solutions when high data quality is required
Heavy reporting workloads
What could be done:
Storage is cheap.
Create duplicate structures that look like real tables
31 of 54
Recursion
Recursion
Powerful modeling technique
Can be used for a number of reasons
 Linked lists (e.g. contract versions)
 Storage of tree structures (e.g. organizational hierarchy)
BUT
Storage mechanisms are wrong, which causes a lot of issues
32 of 54
Pseudo-Recursion Trap
Real recursion
“Kind of”-recursion
THING
THING
ASSOCIATION
from/to date
1 < Child of 0..*
1 < Parent of 0..*
THING
Child of
0..1
0..*
33 of 54
Why is it a trap?
Reasons why people do it:
Versioning
Historical data
Reporting purposes
Long-term project effect:
Hierarchical data consistency is not enforced.
Timing can very easily be off.
34 of 54
Proper Recursive Multi-Tree Model
OrgStruct
- Start_dt
- End_dt
1
OrgStructDtl
1 0..*
OrgUnit
- Type
0..*
0..*
0..1
35 of 54
3.2. Architectural Solutions
36 of 54
Do not hide your business rules!
Business rules should be visible:
Anything published in the database will eventually be used in
ways not initially intended
 … so, changes may have very strange side effects.
Stale code becomes buggy
 … because the context of the whole system may have changed.
Under stress, you may have problems understanding your own
code (especially at 2AM)
 … so, a properly constructed system should prevent you from making
“unforced errors.”
37 of 54
Repository-Based Solutions
Part #1: Repository
Business rules can be explicitly articulated.
You can have version control.
You can even have your own pseudo-language.
Part #2: Code generator
You can either generate program units beforehand or interpret
them during runtime [Dynamic SQL!]
38 of 54
Repository Example
Hundreds of forms
Originally hard-coded
Hard to maintain
Significant development time to add any new forms
Solution:
Generic repository to define object transformation
 Data in the database  data in the form
 Changes in the form  changes in the database
Code generator
 Performance considerations
39 of 54
Mapper Data Model
40 of 54
Impact
Timeline:
Development of new forms had to stop for a month.
In two months – 100% conversion to the new engine
After solution:
Adding a new form takes hours instead of days
 200 forms added in approximately 2 months
Making changes/bug fixes takes minutes
 Change mapping  regenerate  done!
Major architectural changes can be made in 2 days!
 A few updates to the repository  generate  done!
41 of 54
Since then…
The same repository now supports:
 Data transformation inside the database
 Data migration
 Processing data from/to XML
 Offline data export
It is that simple!
 Writing one generator is faster than writing hundreds of routines
Statistic:
 More than 300,000 generated PL/SQL lines of code
42 of 54
3.3. Thick (aka Smart) Database
43 of 54
Using a Thick Database Approach
UI screens NEVER touch tables
… i.e. UI is isolated from the physical data representation as
much as possible
All data-related processes are written using PL/SQL
… since PL/SQL is the most tightly integrated environment to
operate various SQL statements
44 of 54
Micro-SOA at the Database Level
Views and PL/SQL APIs are serving as an isolation level
between data storage and data representation
Advantages:
 A lot of database changes can be absorbed without UI impact
 Edition-based redefinition (EBR) lets you avoid downtime
Disadvantages:
 Requires clear separation of duties between the database and UI team
 Requires knowledgeable database developers (lots of advanced
features!)
 Requires security audits (Dynamic SQL!)
45 of 54
Simplest representative of micro-SOA:
Bring everything your front-end developer needs at once
Capture changes using INSTEAD-OF triggers
 Beware:
Underlying queries tend to grow in complexity
 Stacking various UI views could confuse the CBO
De-Normalized Views
46 of 54
create or replace view v_customer
as
select c.cust_id,
c.name_tx,
a.addr_id,
a.street_tx,
a.state_cd,
a.postal_cd
from customer c
left outer join address a
on c.cust_id = a.cust_id
Example (1)
47 of 54
create or replace trigger v_customer_ii
instead of insert on v_customer
declare
v_cust_id customer.cust_id%rowtype;
begin
if :new.name_tx is not null then
insert into customer
(cust_id,name_tx,phone_tx)
values
(object_seq.nextval,:new.name_tx,:new.phone_tx)
returning cust_id into v_cust_id;
if :new.street_tx is not null then
insert into address
(addr_id,street_tx,state_cd, postal_cd, cust_id)
values (object_seq.nextval,:new.street_tx,
:new.state_cd,:new.postal_cd, v_cust_id);
end if;
end;
Example (2)
48 of 54
Complete isolation:
Data is processed within the PL/SQL function.
The output is an object collection (could be even pipelined!)
Result of function call can be converted to a SQL data set
Extras:
Views can be built on top of functions
Views can have INSTEAD OF triggers
Beware:
Significant performance issues if handled incorrectly
Functions Returning Object Collections
49 of 54
Case:
Complex search engine
 About 20 different filtering criteria
 Applicable to different tables
 Large data volume
Problem:
Unpredictable performance results in a single SQL query.
Use Case (1)
50 of 54
Use Case (2)
 A. Create an output object with corresponding collection.
CREATE type search_ot as object
(Name_TX Varchar2(50),Phone_TX varchar2(20)…)
CREATE type search_nt as table of search_ot;
 B. Create a function to return a collection where all search criteria
become input variables
CREATE OR REPLACE FUNCTION f_search_tt
(i_name_tx varchar2, i_phone_tx varchar2, …)
RETURN search_nt
IS
v_tt search_nt:= search_nt();
BEGIN
RETURN v_tt;
END;
51 of 54
Use Case (3)
 Use Dynamic SQL to build the query
FUNCTION f_search_tt IS
v_sql_tx varchar2(32000);
BEGIN
v_sql_tx:='select search_ot(...) '||chr(10)
'from ... '||chr(10)
'where ...';
if i_name_tx is not null then
v_sql_tx:=v_sql_tx||' and cust.name_tx like ''%'||i_name_tx||'%''
'
end if;
...
execute immediate v_sql_tx bulk collect into v_tt;
...
END;
52 of 54
Use Case (4)
 Give code to developers
select name_tx, address_tx, phone_tx, …
from table(
cast(f_search_nt
(:1, -- name
:2, -- phone
…
)
as search_nt)
)
53 of 54
Conclusions
Good system architecture does matter.
Good system architects play a key role in building
successful systems.
Devoting adequate time and resources to good system
architecture in the short run will always pay off in the long
run.
54 of 54
Contact Information
 Michael Rosenblum – mrosenblum@dulcian.com
 Dulcian, Inc. website - www.dulcian.com
 Blog: wonderingmisha.blogspot.com
Available NOW:
Oracle PL/SQL Performance Tuning Tips & Techniques

More Related Content

Similar to Managing the Earthquake: Surviving Major Database Architecture Changes (rev.2022)

software-architecture-patterns
software-architecture-patternssoftware-architecture-patterns
software-architecture-patterns
Pallav Kumar
 
Fed Up Of Framework Hype Dcphp
Fed Up Of Framework Hype DcphpFed Up Of Framework Hype Dcphp
Fed Up Of Framework Hype Dcphp
Tony Bibbs
 
A Tale of Contemporary Software
A Tale of Contemporary SoftwareA Tale of Contemporary Software
A Tale of Contemporary Software
Yun Zhi Lin
 
Technologies for startup
Technologies for startupTechnologies for startup
Technologies for startup
Dzung Nguyen
 
hints for computer system design by Butler Lampson
hints for computer system design by Butler Lampsonhints for computer system design by Butler Lampson
hints for computer system design by Butler Lampson
mustafa sarac
 
Siegel - keynote presentation, 18 may 2013
Siegel  - keynote presentation, 18 may 2013Siegel  - keynote presentation, 18 may 2013
Siegel - keynote presentation, 18 may 2013
NeilSiegelslideshare
 
Software engineering the genesis
Software engineering  the genesisSoftware engineering  the genesis
Software engineering the genesis
Pawel Szulc
 
Keynote at-icpc-2020
Keynote at-icpc-2020Keynote at-icpc-2020
Keynote at-icpc-2020
Ralf Laemmel
 
Dsys guide37
Dsys guide37Dsys guide37
Dsys guide37
Sattar kayani
 
From Agile Development to Agile Operations (QCon SF 2009)
From Agile Development to Agile Operations (QCon SF 2009)From Agile Development to Agile Operations (QCon SF 2009)
From Agile Development to Agile Operations (QCon SF 2009)
Stuart Charlton
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
Harald Soevik
 
24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)
24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)
24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Craftsmanship
CraftsmanshipCraftsmanship
Craftsmanship
Theo Schlossnagle
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
BlackRabbitCoder
 
To Microservice or Not to Microservice?
To Microservice or Not to Microservice?To Microservice or Not to Microservice?
To Microservice or Not to Microservice?
Eran Stiller
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile Development
Hayim Makabee
 
Sustaining Your Career
Sustaining Your CareerSustaining Your Career
Sustaining Your Career
Scott Lowe
 
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
confluent
 
Complexity 2
Complexity 2Complexity 2
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
 

Similar to Managing the Earthquake: Surviving Major Database Architecture Changes (rev.2022) (20)

software-architecture-patterns
software-architecture-patternssoftware-architecture-patterns
software-architecture-patterns
 
Fed Up Of Framework Hype Dcphp
Fed Up Of Framework Hype DcphpFed Up Of Framework Hype Dcphp
Fed Up Of Framework Hype Dcphp
 
A Tale of Contemporary Software
A Tale of Contemporary SoftwareA Tale of Contemporary Software
A Tale of Contemporary Software
 
Technologies for startup
Technologies for startupTechnologies for startup
Technologies for startup
 
hints for computer system design by Butler Lampson
hints for computer system design by Butler Lampsonhints for computer system design by Butler Lampson
hints for computer system design by Butler Lampson
 
Siegel - keynote presentation, 18 may 2013
Siegel  - keynote presentation, 18 may 2013Siegel  - keynote presentation, 18 may 2013
Siegel - keynote presentation, 18 may 2013
 
Software engineering the genesis
Software engineering  the genesisSoftware engineering  the genesis
Software engineering the genesis
 
Keynote at-icpc-2020
Keynote at-icpc-2020Keynote at-icpc-2020
Keynote at-icpc-2020
 
Dsys guide37
Dsys guide37Dsys guide37
Dsys guide37
 
From Agile Development to Agile Operations (QCon SF 2009)
From Agile Development to Agile Operations (QCon SF 2009)From Agile Development to Agile Operations (QCon SF 2009)
From Agile Development to Agile Operations (QCon SF 2009)
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
 
24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)
24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)
24 Reasons Why Variability Models Are Not Yet Universal (24RWVMANYU)
 
Craftsmanship
CraftsmanshipCraftsmanship
Craftsmanship
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
 
To Microservice or Not to Microservice?
To Microservice or Not to Microservice?To Microservice or Not to Microservice?
To Microservice or Not to Microservice?
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile Development
 
Sustaining Your Career
Sustaining Your CareerSustaining Your Career
Sustaining Your Career
 
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
 
Complexity 2
Complexity 2Complexity 2
Complexity 2
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 

More from Michael Rosenblum

Building a Generic Search Screen using Dynamic SQL
Building a Generic Search Screen using Dynamic SQLBuilding a Generic Search Screen using Dynamic SQL
Building a Generic Search Screen using Dynamic SQL
Michael Rosenblum
 
Managing Unstructured Data: Lobs in the World of JSON
Managing Unstructured Data: Lobs in the World of JSONManaging Unstructured Data: Lobs in the World of JSON
Managing Unstructured Data: Lobs in the World of JSON
Michael Rosenblum
 
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...
Michael Rosenblum
 
Server-Side Development for the Cloud
Server-Side Developmentfor the CloudServer-Side Developmentfor the Cloud
Server-Side Development for the Cloud
Michael Rosenblum
 
Developer's Approach to Code Management
Developer's Approach to Code ManagementDeveloper's Approach to Code Management
Developer's Approach to Code Management
Michael Rosenblum
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
Michael Rosenblum
 
Why is the application running so slowly?
Why is the application running so slowly?Why is the application running so slowly?
Why is the application running so slowly?
Michael Rosenblum
 
Printing without printers
Printing without printersPrinting without printers
Printing without printers
Michael Rosenblum
 
PL/SQL User-Defined Functions in the Read World
PL/SQL User-Defined Functions in the Read WorldPL/SQL User-Defined Functions in the Read World
PL/SQL User-Defined Functions in the Read World
Michael Rosenblum
 
A New View of Database Views
A New View of Database ViewsA New View of Database Views
A New View of Database Views
Michael Rosenblum
 
Data Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your DatabaseData Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your Database
Michael Rosenblum
 

More from Michael Rosenblum (11)

Building a Generic Search Screen using Dynamic SQL
Building a Generic Search Screen using Dynamic SQLBuilding a Generic Search Screen using Dynamic SQL
Building a Generic Search Screen using Dynamic SQL
 
Managing Unstructured Data: Lobs in the World of JSON
Managing Unstructured Data: Lobs in the World of JSONManaging Unstructured Data: Lobs in the World of JSON
Managing Unstructured Data: Lobs in the World of JSON
 
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...
 
Server-Side Development for the Cloud
Server-Side Developmentfor the CloudServer-Side Developmentfor the Cloud
Server-Side Development for the Cloud
 
Developer's Approach to Code Management
Developer's Approach to Code ManagementDeveloper's Approach to Code Management
Developer's Approach to Code Management
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
 
Why is the application running so slowly?
Why is the application running so slowly?Why is the application running so slowly?
Why is the application running so slowly?
 
Printing without printers
Printing without printersPrinting without printers
Printing without printers
 
PL/SQL User-Defined Functions in the Read World
PL/SQL User-Defined Functions in the Read WorldPL/SQL User-Defined Functions in the Read World
PL/SQL User-Defined Functions in the Read World
 
A New View of Database Views
A New View of Database ViewsA New View of Database Views
A New View of Database Views
 
Data Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your DatabaseData Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your Database
 

Recently uploaded

一比一原版布兰登大学毕业证(BU毕业证书)如何办理
一比一原版布兰登大学毕业证(BU毕业证书)如何办理一比一原版布兰登大学毕业证(BU毕业证书)如何办理
一比一原版布兰登大学毕业证(BU毕业证书)如何办理
wkip62b
 
一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样
一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样
一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样
881evgn0
 
Divertidamente SLIDE.pptxufururururuhrurid8dj
Divertidamente SLIDE.pptxufururururuhrurid8djDivertidamente SLIDE.pptxufururururuhrurid8dj
Divertidamente SLIDE.pptxufururururuhrurid8dj
lunaemel03
 
哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样
哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样
哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样
qo1as76n
 
ADESGN3S_Case-Study-Municipal-Health-Center.pdf
ADESGN3S_Case-Study-Municipal-Health-Center.pdfADESGN3S_Case-Study-Municipal-Health-Center.pdf
ADESGN3S_Case-Study-Municipal-Health-Center.pdf
GregMichaelTapawan
 
按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理
按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理
按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理
kuapy
 
欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】
欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】
欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】
jafiradnan336
 
一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理
一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理
一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理
67n7f53
 
modular-kitchen home plan civil engineering.pdf
modular-kitchen home plan civil engineering.pdfmodular-kitchen home plan civil engineering.pdf
modular-kitchen home plan civil engineering.pdf
RashmitaSwain3
 
NHR Engineers Portfolio 2023 2024 NISHANT RATHI
NHR Engineers Portfolio 2023 2024 NISHANT RATHINHR Engineers Portfolio 2023 2024 NISHANT RATHI
NHR Engineers Portfolio 2023 2024 NISHANT RATHI
NishantRathi18
 
Introduction to User experience design for beginner
Introduction to User experience design for beginnerIntroduction to User experience design for beginner
Introduction to User experience design for beginner
ellemjani
 
一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理
一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理
一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理
21uul8se
 
International Upcycling Research Network advisory board meeting 4
International Upcycling Research Network advisory board meeting 4International Upcycling Research Network advisory board meeting 4
International Upcycling Research Network advisory board meeting 4
Kyungeun Sung
 
Heuristics Evaluation - How to Guide.pdf
Heuristics Evaluation - How to Guide.pdfHeuristics Evaluation - How to Guide.pdf
Heuristics Evaluation - How to Guide.pdf
Jaime Brown
 
AHMED TALAAT ARCHITECTURE PORTFOLIO .pdf
AHMED TALAAT ARCHITECTURE PORTFOLIO .pdfAHMED TALAAT ARCHITECTURE PORTFOLIO .pdf
AHMED TALAAT ARCHITECTURE PORTFOLIO .pdf
talaatahm
 
Practical eLearning Makeovers for Everyone
Practical eLearning Makeovers for EveryonePractical eLearning Makeovers for Everyone
Practical eLearning Makeovers for Everyone
Bianca Woods
 
一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理
一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理
一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理
ijk38lw
 
一比一原版肯特大学毕业证UKC成绩单一模一样
一比一原版肯特大学毕业证UKC成绩单一模一样一比一原版肯特大学毕业证UKC成绩单一模一样
一比一原版肯特大学毕业证UKC成绩单一模一样
tobbk6s8
 
一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理
一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理
一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理
k7nm6tk
 
Graphic Design Tools and Software .pptx
Graphic Design Tools and Software   .pptxGraphic Design Tools and Software   .pptx
Graphic Design Tools and Software .pptx
Virtual Real Design
 

Recently uploaded (20)

一比一原版布兰登大学毕业证(BU毕业证书)如何办理
一比一原版布兰登大学毕业证(BU毕业证书)如何办理一比一原版布兰登大学毕业证(BU毕业证书)如何办理
一比一原版布兰登大学毕业证(BU毕业证书)如何办理
 
一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样
一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样
一比一原版美国哥伦比亚大学毕业证Columbia成绩单一模一样
 
Divertidamente SLIDE.pptxufururururuhrurid8dj
Divertidamente SLIDE.pptxufururururuhrurid8djDivertidamente SLIDE.pptxufururururuhrurid8dj
Divertidamente SLIDE.pptxufururururuhrurid8dj
 
哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样
哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样
哪里办理美国中央华盛顿大学毕业证双学位证书原版一模一样
 
ADESGN3S_Case-Study-Municipal-Health-Center.pdf
ADESGN3S_Case-Study-Municipal-Health-Center.pdfADESGN3S_Case-Study-Municipal-Health-Center.pdf
ADESGN3S_Case-Study-Municipal-Health-Center.pdf
 
按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理
按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理
按照学校原版(UIUC文凭证书)伊利诺伊大学|厄巴纳-香槟分校毕业证快速办理
 
欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】
欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】
欧洲杯买球-欧洲杯买球买球网好的网站-欧洲杯买球哪里有正规的买球网站|【​网址​🎉ac123.net🎉​】
 
一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理
一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理
一比一原版(LaTrobe毕业证书)拉筹伯大学毕业证如何办理
 
modular-kitchen home plan civil engineering.pdf
modular-kitchen home plan civil engineering.pdfmodular-kitchen home plan civil engineering.pdf
modular-kitchen home plan civil engineering.pdf
 
NHR Engineers Portfolio 2023 2024 NISHANT RATHI
NHR Engineers Portfolio 2023 2024 NISHANT RATHINHR Engineers Portfolio 2023 2024 NISHANT RATHI
NHR Engineers Portfolio 2023 2024 NISHANT RATHI
 
Introduction to User experience design for beginner
Introduction to User experience design for beginnerIntroduction to User experience design for beginner
Introduction to User experience design for beginner
 
一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理
一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理
一比一原版亚利桑那大学毕业证(UA毕业证书)如何办理
 
International Upcycling Research Network advisory board meeting 4
International Upcycling Research Network advisory board meeting 4International Upcycling Research Network advisory board meeting 4
International Upcycling Research Network advisory board meeting 4
 
Heuristics Evaluation - How to Guide.pdf
Heuristics Evaluation - How to Guide.pdfHeuristics Evaluation - How to Guide.pdf
Heuristics Evaluation - How to Guide.pdf
 
AHMED TALAAT ARCHITECTURE PORTFOLIO .pdf
AHMED TALAAT ARCHITECTURE PORTFOLIO .pdfAHMED TALAAT ARCHITECTURE PORTFOLIO .pdf
AHMED TALAAT ARCHITECTURE PORTFOLIO .pdf
 
Practical eLearning Makeovers for Everyone
Practical eLearning Makeovers for EveryonePractical eLearning Makeovers for Everyone
Practical eLearning Makeovers for Everyone
 
一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理
一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理
一比一原版(Vancouver毕业证书)温哥华岛大学毕业证如何办理
 
一比一原版肯特大学毕业证UKC成绩单一模一样
一比一原版肯特大学毕业证UKC成绩单一模一样一比一原版肯特大学毕业证UKC成绩单一模一样
一比一原版肯特大学毕业证UKC成绩单一模一样
 
一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理
一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理
一比一原版(LSBU毕业证书)伦敦南岸大学毕业证如何办理
 
Graphic Design Tools and Software .pptx
Graphic Design Tools and Software   .pptxGraphic Design Tools and Software   .pptx
Graphic Design Tools and Software .pptx
 

Managing the Earthquake: Surviving Major Database Architecture Changes (rev.2022)

  • 1. 1 of 54 Managing the Earthquake: Surviving Major Database Architecture Changes (rev.2022) Michael Rosenblum www.dulcian.com
  • 2. 2 of 54 Who Am I? – “Misha” Oracle ACE Co-author of 3 books  PL/SQL for Dummies  Expert PL/SQL Practices  Oracle PL/SQL Performance Tuning Tips & Techniques Known for:  SQL and PL/SQL tuning  Complex functionality  Code generators  Repository-based development
  • 3. 3 of 54 Background (1) Year 2011 I didn’t have any gray hair. I had just published my second book. I thought that I knew everything about database development. I had been building IT systems for a WHOLE DECADE!
  • 4. 4 of 54 Background (2) I successfully gave the following presentation:
  • 5. 5 of 54 Background (3) Year 2022: I am slowly starting to resemble Santa Claus. I’ve become tired of publishing. I recognize that knowing everything is impossible. I have been building and maintaining IT systems at the same company for TWO DECADES! 
  • 6. 6 of 54 Background (4) Point of view: Keeping systems alive for years teaches you a lot about good vs. bad architectures.  … and you get a chance to learn from your own mistakes. You recognize strategic vs. tactical trade-offs.  … and you get a chance to learn from your management mistakes.
  • 7. 7 of 54 So… “Managing the Earthquake” rev.2022: 1. Why bother? 2. Trends 3. Best practices
  • 8. 8 of 54 1. Why Bother?!
  • 9. 9 of 54 Does anybody care? Perfectly valid question: Agile development is iterative by its nature. DevOps is focused on continuous delivery   You (theoretically) should be able to rapidly adjust the system to changes. All startups want to deliver something new faster than anybody else (i.e. what matters is V1)
  • 10. 10 of 54 Yes, we do!  Reasons: Changes are inevitable  … so, there will be V2,V3 etc. Patience is a very rare virtue  … i.e. you will be constantly running against the clock. Constraints: Agile development works only sometimes  … and when it doesn’t work – the whole process is SLOW! Efficient DevOps is hard to set up and is often limited in scope  … because data/data storage is the most critical IT asset.
  • 11. 11 of 54 Reality Check Time is limited … otherwise you could just build something new every time. Money is limited … i.e. throwing more developers/hardware may help, but only up to a point. Predictability is limited … i.e. you cannot protect yourself against “unknown unknowns.”
  • 12. 12 of 54 2. Trends
  • 13. 13 of 54 Known Unknowns (1) We ARE going to “the cloud” … but there are different “flavors” of cloud implementations (each with its own limitations/features).  Architectural ramifications: Different pricing mechanisms may require different optimization patterns. Platform-dependent features have to be vetted very carefully.
  • 14. 14 of 54 Example  Case:  During final tests, clients were contemplating Amazon RDS as one of the hosting options. Impact:  At that time, RDS did not support Java within the database. Solution:  Rewrite of Base64 encoding/decoding to become purely PL/SQL- based. Lesson learned:  Hosting decisions must be explicitly spelled out beforehand!
  • 15. 15 of 54 Known Unknowns (2) We ARE working with unstructured/semi-structured data … but that data could be stored in a number of different forms (within an Oracle DB/separate noSQL implementation) Architectural ramifications: Cheap short-term solutions may not scale. Semi-structured data could mutate.
  • 16. 16 of 54 Example Case:  External provider suddenly decided to change communication mechanism from XML to JSON and warned about potential internal JSON changes in the future. Impact:  Historical reporting became complicated. Solution:  To protect existing functionality, extract key data elements out of XML/JSON into a relational table. Lesson learned:  If you have an API-driven system, it is better to have a platform- independent isolation layer in-between.
  • 17. 17 of 54 Known Unknowns (3) You WILL be releasing the next version (sooner than you expect) … and somebody will have to do it. Architectural ramifications: Last 5% of requirements often take the most time. Every system architect should have a clear path between IOC and FOC. Not delivering that last 5% could be a major contract breach.
  • 18. 18 of 54 Example Case:  One consulting company was “dragging their feet” for a couple of years by partially implementing requirements. The company was fired and eventually sued by the client. Research:  I was involved as an expert and was able to prove that the provided architecture was not capable of doing what was promised. Impact:  The consulting company had a huge fine imposed and had to return all of the money earned under that contract. Lesson learned:  Cover-ups have a tendency to blow up!
  • 19. 19 of 54 3. Best Practices
  • 20. 20 of 54 Personal Bragging - Story #1 United States Air Force Recruiting system Initially built in 2003 – contract was just extended for another 5 years Survived:  Shift from single component to multi-component structure  Absorption of various smaller Air Force services  Several internal Air Force hierarchy reorganizations  Transformation from app-based to browser-based  Architectural shifts in recruitment form maintenance  Migration from “on-premises” to “cloud”
  • 21. 21 of 54 Personal Bragging - Story #2 New York State Office of Alcohol and Substance Abuse Services (NYS OASAS) Initially built before I joined Dulcian  - still currently operational Survived:  Rewrite from Oracle Forms to 100% web-based solution without functionality loss (FormSpider©!)  Significant expansion of scope and number of users  Multiple internal architectural shifts
  • 22. 22 of 54 3.1. Data Models
  • 23. 23 of 54 Why Data Modeling Matters  Database structure is the least agile part of the system: It has to be flexible enough to absorb expected “small” changes. It has to be generic enough to simplify “mid-level” changes. The database is the most critical part of the whole system: It has to be understandable enough to prevent inadvertent data corruption. It has to perform well enough for the expected workload.
  • 24. 24 of 54 “Smart Columns” vs. Attributes Column  Represents a single logical attribute  Does not make sense if split “Smart” column  Has internal structure  May even change meaning depending upon the data Opinion:  Major source of problems!  During system migration, I NEVER encountered “smart columns” without some kind of issues.  Avoid them if you can!
  • 25. 25 of 54 Examples of “Smart” Columns Organization rollup  Pipe-delimited combination of Region/State/City/Zip  Long-term project impact:  Adding extra level to rollup became extremely challenging.  Search was very expensive. Answers on questionnaires:  Single text line where number of characters = number of questions: “YYYNNNNYYNY”  Long-term project impact  Developer’s mistake during one release caused data corruption that was detected only after some time  major data recovery project
  • 26. 26 of 54 If it is more than ONE – is it MANY? Correct model: Proper Generalization Org Ship OrgRole - Role_CD 0..* 1 0..1 0..* manage maintain Org Ship 0..1 0..* 0..* 1 0..* repair 0..1
  • 27. 27 of 54 OVER-Generalization Reasons for generic solutions: Changes are costly. We feel “protected” against the future. Generic models are “cool” (especially now with the Big Data movement). BUT Generic solutions often mask an incomplete understanding of the subject area. Generic solutions in one area may cause major issues in others.
  • 28. 28 of 54 Example of Over-Generalization Object AttribValue - Name - Value_NR - Value_DT - Value_TX Assoc 0..* 0..* 0..* 1 1 1
  • 29. 29 of 54 Over-Generalization Problems Data entry: Uses a lot of operations to retrieve a single object Data quality is hard to enforce. Data retrieval Indexes are useless. CBO goes crazy. Performance is sporadic and does not follow any meaningful logic. Functional complex reporting is impossible.
  • 30. 30 of 54 Over-Generalization Potential There are cases when key-value stores are perfect (NoSQL environments). BUT they should not be mixed with: OLTP solutions when high data quality is required Heavy reporting workloads What could be done: Storage is cheap. Create duplicate structures that look like real tables
  • 31. 31 of 54 Recursion Recursion Powerful modeling technique Can be used for a number of reasons  Linked lists (e.g. contract versions)  Storage of tree structures (e.g. organizational hierarchy) BUT Storage mechanisms are wrong, which causes a lot of issues
  • 32. 32 of 54 Pseudo-Recursion Trap Real recursion “Kind of”-recursion THING THING ASSOCIATION from/to date 1 < Child of 0..* 1 < Parent of 0..* THING Child of 0..1 0..*
  • 33. 33 of 54 Why is it a trap? Reasons why people do it: Versioning Historical data Reporting purposes Long-term project effect: Hierarchical data consistency is not enforced. Timing can very easily be off.
  • 34. 34 of 54 Proper Recursive Multi-Tree Model OrgStruct - Start_dt - End_dt 1 OrgStructDtl 1 0..* OrgUnit - Type 0..* 0..* 0..1
  • 35. 35 of 54 3.2. Architectural Solutions
  • 36. 36 of 54 Do not hide your business rules! Business rules should be visible: Anything published in the database will eventually be used in ways not initially intended  … so, changes may have very strange side effects. Stale code becomes buggy  … because the context of the whole system may have changed. Under stress, you may have problems understanding your own code (especially at 2AM)  … so, a properly constructed system should prevent you from making “unforced errors.”
  • 37. 37 of 54 Repository-Based Solutions Part #1: Repository Business rules can be explicitly articulated. You can have version control. You can even have your own pseudo-language. Part #2: Code generator You can either generate program units beforehand or interpret them during runtime [Dynamic SQL!]
  • 38. 38 of 54 Repository Example Hundreds of forms Originally hard-coded Hard to maintain Significant development time to add any new forms Solution: Generic repository to define object transformation  Data in the database  data in the form  Changes in the form  changes in the database Code generator  Performance considerations
  • 39. 39 of 54 Mapper Data Model
  • 40. 40 of 54 Impact Timeline: Development of new forms had to stop for a month. In two months – 100% conversion to the new engine After solution: Adding a new form takes hours instead of days  200 forms added in approximately 2 months Making changes/bug fixes takes minutes  Change mapping  regenerate  done! Major architectural changes can be made in 2 days!  A few updates to the repository  generate  done!
  • 41. 41 of 54 Since then… The same repository now supports:  Data transformation inside the database  Data migration  Processing data from/to XML  Offline data export It is that simple!  Writing one generator is faster than writing hundreds of routines Statistic:  More than 300,000 generated PL/SQL lines of code
  • 42. 42 of 54 3.3. Thick (aka Smart) Database
  • 43. 43 of 54 Using a Thick Database Approach UI screens NEVER touch tables … i.e. UI is isolated from the physical data representation as much as possible All data-related processes are written using PL/SQL … since PL/SQL is the most tightly integrated environment to operate various SQL statements
  • 44. 44 of 54 Micro-SOA at the Database Level Views and PL/SQL APIs are serving as an isolation level between data storage and data representation Advantages:  A lot of database changes can be absorbed without UI impact  Edition-based redefinition (EBR) lets you avoid downtime Disadvantages:  Requires clear separation of duties between the database and UI team  Requires knowledgeable database developers (lots of advanced features!)  Requires security audits (Dynamic SQL!)
  • 45. 45 of 54 Simplest representative of micro-SOA: Bring everything your front-end developer needs at once Capture changes using INSTEAD-OF triggers  Beware: Underlying queries tend to grow in complexity  Stacking various UI views could confuse the CBO De-Normalized Views
  • 46. 46 of 54 create or replace view v_customer as select c.cust_id, c.name_tx, a.addr_id, a.street_tx, a.state_cd, a.postal_cd from customer c left outer join address a on c.cust_id = a.cust_id Example (1)
  • 47. 47 of 54 create or replace trigger v_customer_ii instead of insert on v_customer declare v_cust_id customer.cust_id%rowtype; begin if :new.name_tx is not null then insert into customer (cust_id,name_tx,phone_tx) values (object_seq.nextval,:new.name_tx,:new.phone_tx) returning cust_id into v_cust_id; if :new.street_tx is not null then insert into address (addr_id,street_tx,state_cd, postal_cd, cust_id) values (object_seq.nextval,:new.street_tx, :new.state_cd,:new.postal_cd, v_cust_id); end if; end; Example (2)
  • 48. 48 of 54 Complete isolation: Data is processed within the PL/SQL function. The output is an object collection (could be even pipelined!) Result of function call can be converted to a SQL data set Extras: Views can be built on top of functions Views can have INSTEAD OF triggers Beware: Significant performance issues if handled incorrectly Functions Returning Object Collections
  • 49. 49 of 54 Case: Complex search engine  About 20 different filtering criteria  Applicable to different tables  Large data volume Problem: Unpredictable performance results in a single SQL query. Use Case (1)
  • 50. 50 of 54 Use Case (2)  A. Create an output object with corresponding collection. CREATE type search_ot as object (Name_TX Varchar2(50),Phone_TX varchar2(20)…) CREATE type search_nt as table of search_ot;  B. Create a function to return a collection where all search criteria become input variables CREATE OR REPLACE FUNCTION f_search_tt (i_name_tx varchar2, i_phone_tx varchar2, …) RETURN search_nt IS v_tt search_nt:= search_nt(); BEGIN RETURN v_tt; END;
  • 51. 51 of 54 Use Case (3)  Use Dynamic SQL to build the query FUNCTION f_search_tt IS v_sql_tx varchar2(32000); BEGIN v_sql_tx:='select search_ot(...) '||chr(10) 'from ... '||chr(10) 'where ...'; if i_name_tx is not null then v_sql_tx:=v_sql_tx||' and cust.name_tx like ''%'||i_name_tx||'%'' ' end if; ... execute immediate v_sql_tx bulk collect into v_tt; ... END;
  • 52. 52 of 54 Use Case (4)  Give code to developers select name_tx, address_tx, phone_tx, … from table( cast(f_search_nt (:1, -- name :2, -- phone … ) as search_nt) )
  • 53. 53 of 54 Conclusions Good system architecture does matter. Good system architects play a key role in building successful systems. Devoting adequate time and resources to good system architecture in the short run will always pay off in the long run.
  • 54. 54 of 54 Contact Information  Michael Rosenblum – mrosenblum@dulcian.com  Dulcian, Inc. website - www.dulcian.com  Blog: wonderingmisha.blogspot.com Available NOW: Oracle PL/SQL Performance Tuning Tips & Techniques