Thanks for the initial answer — it's very helpful. I’d like to refine my original architectural question and ask for further guidance on a few specific points.
1. Does the 4-schema architecture make sense for a SmartDB (Thick DB) paradigm / Oracle APEX project?
My intent with this separation was to strictly enforce the principle of least privilege:
DATA_LAYER: Tables only
LOGIC_LAYER: Private logic (packages) accessing DATA_LAYER
API_LAYER: Public PL/SQL interface (packages) consuming LOGIC_LAYER
APEX_UI_LAYER: Parsing schema only has EXECUTE on API_LAYER
This parallels what I understand of the SmartDB (ThickDB) paradigm — i.e., all SELECT/INSERT/UPDATE/DELETE are done only via PL/SQL APIs inside the database, not ad-hoc queries from the UI.
Source:
https://stevenfeuersteinonplsql.blogspot.com/2018/05/the-smartdb-resource-center.html?utm_source=chatgpt.com But I’m wondering if 4 schemas if there’s a recommended practice for how many layers/schema I should have in a SmartDB design for Oracle APEX.
Questions:
* Is strict 4-schema separation worth the complexity?
* In your opinion, what should it be the schema separation a reasonable and recommended approach for SmartDB with Oracle APEX?
2. How should this be implemented in Oracle APEX?
Originally I asked about pipelined functions vs views for reporting. After reading your answer, it appears that using pipelined functions purely as “SELECT * FROM …” wrappers limits the optimizer’s ability to use indexes and push predicates.
So my revised question is:
When applying the SmartDB paradigm in APEX reporting (Interactive Reports, Grids, Classic Reports), what’s the recommended way to expose data? Should I use views instead of pipelined functions for read operations?
3. How to deal with grants on views?
If I use views for read access across schemas, how should the grants be managed?
Should I avoid using WITH GRANT OPTION on views to avoid privilege escalation? Should I use roles? How should the API_LAYER reach those views (should the API_LAYER own the views and select directly from DATA_LAYER — even though that crosses layers?)?
Any best practices around secure and least-privilege grants in this multi-schema pattern?
4. Example
Here’s a simple example of what I think might be a view-based alternative to the pipelined approach shown previously:
-- DATA layer
CREATE TABLE data_layer.departments (
department_id NUMBER PRIMARY KEY,
department_name VARCHAR2(100)
);
-- API layer (or logic layer, if preferred)
CREATE OR REPLACE VIEW api_layer.v_departments AS
SELECT
department_id,
department_name
FROM
data_layer.departments;
-- Grants
GRANT SELECT ON data_layer.departments TO api_layer; -- read only
GRANT SELECT ON api_layer.v_departments TO apex_ui_layer;Is this kind of view model a good approach in SmartDB for APEX reporting?
Or do you recommend something else?