Schema query

Contains tables designed to represent user-defined queries for reports and the like.

Table: bind_variable

Columns: 

field name : datatype -- parameters, contraints and notes
name : text -- PRIMARY KEY,
type : text -- NOT NULL,
description : text -- NOT NULL,
default_value : text --
label : text -- NOT NULL,

Constraints: 

bind_variable_type : CHECK ((type = ANY (ARRAY['string'::text, 'number'::text, 'string_list'::text, 'number_list'::text])))

Tables referencing query.expression via Foreign Key Constraints: 

query.expression 

Table: case_branch

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
parent_expr : integer -- UNIQUE#1, NOT NULL, REFERENCES query.expression.
seq_no : integer -- UNIQUE#1, NOT NULL,
condition : integer -- REFERENCES query.expression.
result : integer -- NOT NULL, REFERENCES query.expression.

Table: datatype

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
datatype_name : text -- UNIQUE, NOT NULL,
is_numeric : boolean -- NOT NULL, DEFAULT false,
is_composite : boolean -- NOT NULL, DEFAULT false,

Constraints: 

qdt_comp_not_num : CHECK (((is_numeric IS FALSE) OR (is_composite IS FALSE)))

Tables referencing query.expression via Foreign Key Constraints: 

query.expressionquery.function_param_def
query.function_sigquery.record_column
query.subfield 

View: expr_xbet

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
left_operand : integer --
negate : boolean --

View: expr_xbind

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
bind_variable : text --

View: expr_xbool

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
literal : text --
negate : boolean --

View: expr_xcase

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
left_operand : integer --
negate : boolean --

View: expr_xcast

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
left_operand : integer --
cast_type : integer --
negate : boolean --

View: expr_xcol

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
table_alias : text --
column_name : text --
negate : boolean --

View: expr_xex

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
subquery : integer --
negate : boolean --

View: expr_xfunc

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
column_name : text --
function_id : integer --
negate : boolean --

View: expr_xin

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
left_operand : integer --
subquery : integer --
negate : boolean --

View: expr_xisnull

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
left_operand : integer --
negate : boolean --

View: expr_xnull

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
negate : boolean --

View: expr_xnum

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
literal : text --

View: expr_xop

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
left_operand : integer --
operator : text --
right_operand : integer --
negate : boolean --

View: expr_xser

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
operator : text --
negate : boolean --

View: expr_xstr

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
literal : text --

View: expr_xsubq

Columns: 

field name : datatype -- parameters, contraints and notes
id : integer --
parenthesize : boolean --
parent_expr : integer --
seq_no : integer --
subquery : integer --
negate : boolean --

Table: expression

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
type : text -- NOT NULL,
parenthesize : boolean -- NOT NULL, DEFAULT false,
parent_expr : integer -- REFERENCES query.expression.
seq_no : integer -- NOT NULL, DEFAULT 1,
literal : text --
table_alias : text --
column_name : text --
left_operand : integer -- REFERENCES query.expression.
operator : text --
right_operand : integer -- REFERENCES query.expression.
function_id : integer -- REFERENCES query.function_sig.
subquery : integer -- REFERENCES query.stored_query.
cast_type : integer -- REFERENCES query.datatype.
negate : boolean -- NOT NULL, DEFAULT false,
bind_variable : text -- REFERENCES query.bind_variable.

Constraints: 

expression_type : CHECK ((type = ANY (ARRAY['xbet'::text, 'xbind'::text, 'xbool'::text, 'xcase'::text, 'xcast'::text, 'xcol'::text, 'xex'::text, 'xfunc'::text, 'xin'::text, 'xisnull'::text, 'xnull'::text, 'xnum'::text, 'xop'::text, 'xser'::text, 'xstr'::text, 'xsubq'::text])))

Tables referencing query.case_branch via Foreign Key Constraints: 

query.case_branchquery.expression
query.from_relationquery.order_by_item
query.select_itemquery.stored_query

Table: from_relation

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
type : text -- NOT NULL,
table_name : text --
class_name : text --
subquery : integer -- REFERENCES query.stored_query.
function_call : integer -- REFERENCES query.expression.
table_alias : text --
parent_relation : integer -- REFERENCES query.from_relation.
seq_no : integer -- NOT NULL, DEFAULT 1,
join_type : text --
on_clause : integer -- REFERENCES query.expression.

Constraints: 

good_join_type : CHECK (((join_type IS NULL) OR (join_type = ANY (ARRAY['INNER'::text, 'LEFT'::text, 'RIGHT'::text, 'FULL'::text]))))
join_or_core : CHECK (((((parent_relation IS NULL) AND (join_type IS NULL)) AND (on_clause IS NULL)) OR (((parent_relation IS NOT NULL) AND (join_type IS NOT NULL)) AND (on_clause IS NOT NULL))))
relation_type : CHECK ((type = ANY (ARRAY['RELATION'::text, 'SUBQUERY'::text, 'FUNCTION'::text])))

Tables referencing query.from_relation via Foreign Key Constraints: 

query.from_relationquery.record_column
query.stored_query 

Table: function_param_def

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
function_id : integer -- UNIQUE#1, NOT NULL, REFERENCES query.function_sig.
seq_no : integer -- UNIQUE#1, NOT NULL,
datatype : integer -- NOT NULL, REFERENCES query.datatype.

Constraints: 

qfpd_pos_seq_no : CHECK ((seq_no > 0))

Table: function_sig

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
function_name : text -- NOT NULL,
return_type : integer -- REFERENCES query.datatype.
is_aggregate : boolean -- NOT NULL, DEFAULT false,

Constraints: 

qfd_rtn_or_aggr : CHECK (((return_type IS NULL) OR (is_aggregate = false)))

Indexes: 

query_function_sig_name_idx : function_name

Tables referencing query.expression via Foreign Key Constraints: 

query.expressionquery.function_param_def

Table: order_by_item

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
stored_query : integer -- UNIQUE#1, NOT NULL, REFERENCES query.stored_query.
seq_no : integer -- UNIQUE#1, NOT NULL,
expression : integer -- NOT NULL, REFERENCES query.expression.

Table: query_sequence

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
parent_query : integer -- UNIQUE#1, NOT NULL, REFERENCES query.stored_query.
seq_no : integer -- UNIQUE#1, NOT NULL,
child_query : integer -- NOT NULL, REFERENCES query.stored_query.

Table: record_column

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
from_relation : integer -- UNIQUE#1, NOT NULL, REFERENCES query.from_relation.
seq_no : integer -- UNIQUE#1, NOT NULL,
column_name : text -- NOT NULL,
column_type : integer -- NOT NULL, REFERENCES query.datatype.

Table: select_item

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
stored_query : integer -- UNIQUE#1, NOT NULL, REFERENCES query.stored_query.
seq_no : integer -- UNIQUE#1, NOT NULL,
expression : integer -- NOT NULL, REFERENCES query.expression.
column_alias : text --
grouped_by : boolean -- NOT NULL, DEFAULT false,

Table: stored_query

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
type : text -- NOT NULL,
use_all : boolean -- NOT NULL, DEFAULT false,
use_distinct : boolean -- NOT NULL, DEFAULT false,
from_clause : integer -- REFERENCES query.from_relation.
where_clause : integer -- REFERENCES query.expression.
having_clause : integer -- REFERENCES query.expression.
limit_count : integer -- REFERENCES query.expression.
offset_count : integer -- REFERENCES query.expression.

Constraints: 

query_type : CHECK ((type = ANY (ARRAY['SELECT'::text, 'UNION'::text, 'INTERSECT'::text, 'EXCEPT'::text])))

Tables referencing action.fieldset via Foreign Key Constraints: 

action.fieldsetquery.expression
query.from_relationquery.order_by_item
query.query_sequencequery.select_item

Table: subfield

Columns: 

field name : datatype -- parameters, contraints and notes
id : serial -- PRIMARY KEY,
composite_type : integer -- UNIQUE#1, NOT NULL, REFERENCES query.datatype.
seq_no : integer -- UNIQUE#1, NOT NULL,
subfield_type : integer -- NOT NULL, REFERENCES query.datatype.

Constraints: 

qsf_pos_seq_no : CHECK ((seq_no > 0))