Skip to content

Instantly share code, notes, and snippets.

@cyhsutw
Created June 16, 2014 06:47
Show Gist options
  • Save cyhsutw/836753bb6c5b3072d8b0 to your computer and use it in GitHub Desktop.
Save cyhsutw/836753bb6c5b3072d8b0 to your computer and use it in GitHub Desktop.
CREATE VIEW birth_record AS
SELECT p.id AS person_id,
p.given_name AS given_name,
p.birthday AS date_of_birth,
h.country AS country_of_birth,
m.given_name AS mother_name
FROM birth p, hospital h, birth m
WHERE p.mother_id = m.id AND p.hospital_id = h.id ORDER BY p.id ASC;
CREATE VIEW death_certificate AS
SELECT d.person_id AS person_id,
d.time AS date_of_death,
d.confirmed AS death_confirmed
FROM death d;
CREATE VIEW criminal_record AS
SELECT c.person_id AS person_id,
c.date AS date_of_crime,
c.outcome AS legal_outcome,
c.status AS legal_status,
c.closing_date AS date_of_closing_crime
FROM criminal c;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment