-
-
Save spion/d60382ff2787967cb104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table male | |
( male_id int not null | |
, primary key (male_id) ); | |
create table female | |
( female_id int not null | |
, primary key (female_id) ); | |
create table name | |
( id int not null | |
, name text not null | |
, primary key (id)); | |
create view gender as | |
select 'm' as gender, male_id as id from male | |
union | |
select 'f' as gender, female_id as id from female; | |
create view person as | |
select n.id, n.name, g.gender | |
from name n join gender g on n.id = g.id; | |
insert into name values (1, 'John'); | |
insert into male values (1); | |
insert into name values (2, 'Jane'); | |
insert into female values(2); | |
select * from person; | |
update name set name = @new_name where id = @person_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment