- Script (init.sql)
Create a database called ddl_exercise. Create a table named people in this database, with columns id integer, name varchar(50) and surname varchar(50).
Column id should be an auto incrementing primary key.
- Script (migration1.sql)
- Now add columns
age integer,sex char(1)andposition varchar(50)to this table. - increase the size for
surnameto 100 characters. - get rid of
positioncolumn (we changed our mind)
- Script (seeds.sql)
Fill the table with some rows (it's up to you to make them) so that we have 5 men and 5 women in it and:
- 2 people of less than 10 years,
- 2 people between 10-20,
- 2 people between 20-30,
- 2 people between 30-40,
- 2 people older than 40 years.
- Script (migration2.sql)
- Add column
title varchar(10)and set it for all the people in following way- people older than 20 should have it set to
Eng. - people older than 30 years should have it set to
Dr. - people older than 40 years should have it set to
Prof.
- people older than 20 should have it set to
- Delete all men younger than 10 years
- Create table
positionswith columnsid integer,person_id integer,position varchar(50)and set theperson_idas a foreign key to tablepeopleand its columnid - Create
professors, which should be a copy (schema & data) ofpeopletable, but holding only records about professors.