- Add a
not nullconstraint to a column - Insert rows into a table
- Select rows from a table
- Update rows from a table
- Delete rows from a table
- Drop tables
- Add primary and foreign key constraints to a table
- Add rows to a tables that have one-to-many and many-to-many relationships
- Select using join tables
Create a table with the following columns
- id - serial
- fname - varchar(255) not null
- lname - varchar(255) not null
- github - varchar(255) not null
- title - varchar(255) not null
- dndclass - varchar(255)
insert into instructors (fname, lname, github, title, dndclass) values ('Roger', 'Schmidt', 'rogerwschmidt', 'Lead Instructor', 'barbarian');- Insert 3 more instructors into the
instructorstable, make sure that at least one does not have adndclass
select * from instructors;- Select an instructor by their
id - Select an instructor by their
title - Select an instructor if they do not have a dnd class
update instructors set fname='Rogelio' where id=1(note:idmay be different)- Update the dnd class for the instructor that is missing it
delete from instructors where id=1- Delete an instructor based on their id
drop table instructors
create table cohorts (
id serial primary key,
name varchar(255)
);
create table students (
id serial primary key,
fname varchar(255),
lname varchar(255),
cohort_id integer not null references cohorts(id)
);
create table instructors (
id serial primary key,
fname varchar(255) not null,
lname varchar(255) not null,
github varchar(255) not null,
title varchar(255) not null,
dndclass varchar(255)
);
create table instructors_cohorts (
id serial primary key,
instructors_id integer not null references instructors (id),
cohorts_id integer not null references cohorts (id)
);
insert into instructors (fname, lname, github, title, dndclass) values ('Roger', 'Schmidt', 'rogerwschmidt', 'Lead Instructor', 'barbarian');- Insert 3 more instructors into the
instructorstable - Insert 2 cohorts into the
cohortstable - Insert 10 students into the
studentstable - Create the association between the
isntructorsand cohorts table
- Select all students with their cohorts