Skip to content

Instantly share code, notes, and snippets.

@dstreev
Created July 8, 2015 20:07
Show Gist options
  • Save dstreev/89627fcd598a58bde641 to your computer and use it in GitHub Desktop.
Save dstreev/89627fcd598a58bde641 to your computer and use it in GitHub Desktop.
Example of Phoenix Overloading
DROP VIEW
IF EXISTS phoenix_overload.profile;
DROP VIEW
IF EXISTS phoenix_overload.relationship;
DROP VIEW
IF EXISTS phoenix_overload.primary_residence;
DROP VIEW
IF EXISTS phoenix_overload.demographic;
DROP VIEW
IF EXISTS phoenix_overload.entity;
DROP TABLE
IF EXISTS phoenix_overload.person_base;
CREATE TABLE
IF NOT EXISTS phoenix_overload.person_base
(
id VARCHAR CONSTRAINT pk_person PRIMARY KEY(id ASC)
) ;
CREATE VIEW
IF NOT EXISTS phoenix_overload.entity
(
first_name VARCHAR,
last_name VARCHAR
) AS
SELECT
*
FROM
phoenix_overload.person_base;
CREATE VIEW
IF NOT EXISTS phoenix_overload.demographic
(
age INTEGER,
gender VARCHAR
) AS
SELECT
*
FROM
phoenix_overload.person_base;
CREATE VIEW
IF NOT EXISTS phoenix_overload.primary_residence
(
prim_addr VARCHAR,
prim_st VARCHAR
) AS
SELECT
*
FROM
phoenix_overload.person_base;
CREATE VIEW
IF NOT EXISTS phoenix_overload.relationship
(
father VARCHAR,
spouse VARCHAR
) AS
SELECT
*
FROM
phoenix_overload.person_base;
CREATE VIEW
IF NOT EXISTS phoenix_overload.profile
(
first_name VARCHAR,
last_name VARCHAR,
age INTEGER,
gender VARCHAR
) AS
SELECT
*
FROM
phoenix_overload.person_base;
CREATE VIEW
IF NOT EXISTS phoenix_overload.full_entity
(
first_name VARCHAR,
last_name VARCHAR,
age INTEGER,
gender VARCHAR,
prim_addr VARCHAR,
prim_st VARCHAR,
father VARCHAR,
spouse VARCHAR
) AS
SELECT
*
FROM
phoenix_overload.person_base;
UPSERT INTO phoenix_overload.profile(id, first_name, last_name, age, gender) VALUES('123','Fred',
'Flintstone',35,'Male') ;
SELECT
*
FROM
phoenix_overload.entity;
SELECT
*
FROM
phoenix_overload.demographic;
UPSERT INTO phoenix_overload.relationship(id, father, spouse) VALUES('123',NULL,'Wilma') ;
SELECT
*
FROM
phoenix_overload.full_entity;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment