reconciling apex and the thick database paradigm · reconciling apex and the thick database...
TRANSCRIPT
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Reconciling APEXand the Thick Database Paradigm
@BrynLite
Product Manager for PL/SQL and EBR at Oracle HQ
Not known for my brevity.Having trouble squeezing my own views—not necessarily my employer's—into 140 chars.Or, for that matter, 60 minutes.
Spring 2017
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Introductoryremarks
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Discussion with
– Niels de Bruijn & Joel Kallman at DOAG
– Toon Koppelaars
– Steven Feuerstein, Dan McGann, et al
– Cary Millsap
–Marc Sewtz & Dan McGann (yesterday)
– etc., etc...
• The “commit in PL/SQL is bad” twitter storm—October 2016
• The Gerald Venzl, Tim Hall, et al “old farts brigade” accusation
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Setting the scope
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Developers write software for a huge variety of purposes
• We need to set the scope for our discussion
• The best way is to think of a modern app like Moovit
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Agenda
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
The case for implementing all business logic inside the database
- Modular design principles applied to applications backed by Oracle Database
- What is SQL, and how do you make it happen?
- The “hard shell” paradigm
- PL/SQL’s unique specific features for making SQL happen
Myth busting
- Data rules can be enforced by code outside of the database
- You can save database CPU and improve scalability by implementing business logic outside the database
- You can rely on robotically generated SQL
- You can change code in the database without application downtime
- There’s no tooling for PL/SQL
- You can’t provide each developer with a private sandbox for PL/SQL development
1
2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Setting the scene
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Large software systems must be built from modules. A module hides its implementation behind an interface that exposes its functionality. This is computer science’s most famous principle.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Large software systems must be built from modules. A module hides its implementation behind an interface that exposes its functionality. This is computer science’s most famous principle.
• For applications that use an Oracle Database, the database is the persistence module. The tables and the SQL statements that manipulate them are the implementation details. The interface is expressed with PL/SQL.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Large software systems must be built from modules. A module hides its implementation behind an interface that exposes its functionality. This is computer science’s most famous principle.
• For applications that use an Oracle Database, the database is the persistence module. The tables and the SQL statements that manipulate them are the implementation details. The interface is expressed with PL/SQL.
• Developers and end-users of applications built this way are happy with their correctness, maintainability, security, and performance.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Large software systems must be built from modules. A module hides its implementation behind an interface that exposes its functionality. This is computer science’s most famous principle.
• For applications that use an Oracle Database, the database is the persistence module. The tables and the SQL statements that manipulate them are the implementation details. The interface is expressed with PL/SQL.
• Developers and end-users of applications built this way are happy with their correctness, maintainability, security, and performance.
• But when developers follow the NoPlsql paradigm, their applications have problems in each of these areas and end-users suffer.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
And yet…
Number of Programming Jobs Ranked by Language (Dice.com data) Summer 2015www.codingdojo.com/blog/8-most-in-demand-programming-languages-of-2015/
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Modular design principles applied to applications backed by Oracle Database
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
what are the modules?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
business functions matter
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
table designs can change
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
responsibility needs authority
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
encase the database in a hard shell
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
the framework alternative
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
NoAnything
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
What is SQL?
How do youmake it happen?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
a SQL statement describes its intended effect
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
you need an if-then-else language to make SQL happen
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
how good is it at doing SQL?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
where does it run?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
The hard shellparadigm
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
commit
insert
delete
update
select
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
commit
insert
delete
update
select
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
commit
insert
delete
update
select
sN
s5
s2
s4
s7s3
s1
s6
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
commit
insert
delete
update
select
ORDS
sN
s5
s2
s4
s7s3
s1
s6
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
-- primitive anonymous block statement
begin Pkg.Bulk_Insert(:Rows); end;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
PL/SQL’s uniquespecific featuresfor making SQL happen
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
procedure p(Lo in t.c3%type, Hi in t.c3%type) is
begin
for r in (
select t.c1, t.c2
from t
where t.c3 between p.Lo and p.Hi
order by 1)
loop
Buffer_Row_For_Display(r.c1, r.c2);
end loop;
end p;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
procedure p(Lo in t.c3%type, Hi in t.c3%type) is
begin
for r in (
select t.c1, t.c2
from t
where t.c3 between p.Lo and p.Hi
order by 1)
loop
Buffer_Row_For_Display(r.c1, r.c2);
end loop;
end p;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
procedure p(Lo in t.c3%type, Hi in t.c3%type) is
begin
for r in (
select t.c1, t.c2
from t
where t.c3 between p.Lo and p.Hi
order by 1)
loop
Buffer_Row_For_Display(r.c1, r.c2);
end loop;
end p;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
procedure p(Lo in t.c3%type, Hi in t.c3%type) is
begin
for r in (
select t.c1, t.c2
from t
where t.c3 between p.Lo and p.Hi
order by 1)
loop
Buffer_Row_For_Display(r.c1, r.c2);
end loop;
end p;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SELECT T.C1, T.C2
FROM T
WHERE T.C3 BETWEEN :B2 AND :B1
ORDER BY 1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
procedure p(Lo in t.c3%type, Hi in t.c3%type) is
begin
for r in ( -- cursor implicitly openedselect t.c1, t.c2
from t
where t.c3 between p.Lo and p.Hi
order by 1)
loop
Buffer_Row_For_Display(r.c1, r.c2);
end loop; -- cursor implicitly closedend p;
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
procedure p(Lo in t.c3%type, Hi in t.c3%type) is
begin
for r in (
select t.c1, t.c2
from t
where t.c3 between p.Lo and p.Hi
order by 1)
loop
Buffer_Row_For_Display(r.c1, r.c2);
end loop;
end p; bulkification
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
native dynamic SQL – expressive – rarely needed
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
no make: the promise brought by static dependency tracking
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
every single artifact that implements the business functionsis in one managed universe: the Oracle Database
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
metadata for everythingstatic definitions
run-time behaviorhomogeneously available via SQL and PL/SQL
for mechanical analysis
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
metadata for everythingstatic definitions
run-time behaviorhomogeneously available via SQL and PL/SQL
for mechanical analysis
DBA_Objects, DBA_Source, DBA_Procedures,DBA_Arguments, DBA_Identifiers, DBA_Dependencies,
DBA_Tables, DBA_Indexes, DBA_Constraints,DBA_Views, DBA_Sequences, DBA_Triggers,...
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
metadata for everythingstatic definitions
run-time behaviorhomogeneously available via SQL and PL/SQL
for mechanical analysis
v$Sql, DBMS_Xplan, DBMS_Hprof,....
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
everything you’d ordinarily expect as a programmerSQL Developer, GUI debugging
compiler warnings (bad SQL aware)conditional compilation tests package globlals
and so on...
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
DeployingPL/SQL code changeswith zero downtime:EBR is the key
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Oracle E-Business Release 12.2 does it
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Salesforce.com does it
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
American Express does it
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
and so can you!
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Empoweringeach developerto provisiontheir own databases
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
PDBs as sandboxes – snapshot clone
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
provisioning app with PL/SQL API from SQL*Plus or APEX
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
trash a test database and then
re-instate it in its pristine starting state
in minutes
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
difference in kind
becomes difference in degree
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
“Oracle Database Development Engineer” job role now well-defined
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
can: schema design, SQL (incl. execution plans), PL/SQL
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
need not know: RMAN, Data Guard, RAC deployment, etc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Conclusion
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
an application whose data isn’t persisted and retrieved correctlyis worthless
“it’s the data, stupid!”
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
an application whose data isn’t persisted and retrieved correctlyis worthless
“it’s the data, stupid!”
protect your data inside a hard PL/SQL shellselect, insert, update, delete come only from PL/SQL
it’s the time-honored way
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
an application whose data isn’t persisted and retrieved correctlyis worthless
“it’s the data, stupid!”
protect your data inside a hard PL/SQL shellselect, insert, update, delete come only from PL/SQL
it’s the time-honored way
performance and security matter toothe thick database paradigm ensures these
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
And now,stepping out of rôle,let’s look at somereal codereally running…
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Internet-facing self-service app to manage your bank account
• Tables:– Account_Kinds– Account_Holders– Accounts– Transactions
...and so on...
• Business function: Transfer funds internally– insert a row into Account_Kinds– Honor the rules:
“can’t go into the red”“can’t xfer more than threshold amount in a calendar month”...and so on..
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Switch to demo
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.