CREATE TABLE "students"(
  "student_iid" serial primary key,
  "fullname" varchar(256) not null,
  "birth_date" date
);

create table "courses" (
  "course_iid" serial primary key,
  "code" varchar(32) not null,
  "name" varchar(128) not null,
  "start_date" date not null,
  "end_date" date not null
);

create table "enrollments"(
  "enrollment_iid" serial primary key,
  "course_iid" integer not null,
  "student_iid" integer not null,
  "enrollment_date" date not null,
  "payment_date" date not null,
  "paid" boolean not null,
  foreign key ("course_iid") references "courses"("course_iid"),
  foreign key ("student_iid") references "students"("student_iid")
);



insert into "students"("fullname", "birth_date")
  values('juan perez', '10-11-2000'),
        ('pepa pig', '13-10-2001'),
        ('jimmy neutron', '03-05-2002'),
        ('james rodriguez', '08-09-2000'),
        ('ana frank', '04-07-2000'),
        ('jorge nitales', '02-03-2004'),
        ('andrea chipreto', '04-01-2005'),
        ('natalia monges', '30-11-1995'),
        ('patricia ramirez', '14-06-1994'),
        ('luhana gonzales', '07-08-1999');


insert into "courses" ("code", "name", "start_date", "end_date")
  values('code001', 'Matematicas', '02-02-2020', '03-05-2022'),
        ('code002', 'Ingles', '03-02-2020', '03-08-2020'),
        ('code003', 'Programacion', '07-02-2020', '07-05-2020'),
        ('code004', 'Quimica', '08-02-2020', '08-05-2020'),
        ('code005', 'Fisica', '09-02-2020', '09-05-2020');


insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=1),
    (select "student_iid" from "students" where "student_iid"=1),
    '06-01-2020', '02-02-2020', 'false');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=1),
    (select "student_iid" from "students" where "student_iid"=2),
    '06-01-2020', '02-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=1),
    (select "student_iid" from "students" where "student_iid"=3),
    '06-01-2020', '02-02-2020', 'false');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=1),
    (select "student_iid" from "students" where "student_iid"=4),
    '06-01-2020', '02-02-2020', 'false');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=1),
    (select "student_iid" from "students" where "student_iid"=5),
    '06-01-2020', '02-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=2),
    (select "student_iid" from "students" where "student_iid"=1),
    '06-01-2020', '03-02-2020', 'false');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=2),
    (select "student_iid" from "students" where "student_iid"=2),
    '06-01-2020', '03-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=2),
    (select "student_iid" from "students" where "student_iid"=3),
    '06-01-2020', '03-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=2),
    (select "student_iid" from "students" where "student_iid"=10),
    '06-01-2020', '03-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=2),
    (select "student_iid" from "students" where "student_iid"=7),
    '06-01-2020', '03-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=3),
    (select "student_iid" from "students" where "student_iid"=1),
    '06-01-2020', '07-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=3),
    (select "student_iid" from "students" where "student_iid"=2),
    '06-01-2020', '07-02-2020', 'false');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=3),
    (select "student_iid" from "students" where "student_iid"=10),
    '06-01-2020', '07-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=3),
    (select "student_iid" from "students" where "student_iid"=4),
    '06-01-2020', '07-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=3),
    (select "student_iid" from "students" where "student_iid"=10),
    '06-01-2020', '07-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=4),
    (select "student_iid" from "students" where "student_iid"=1),
    '06-01-2020', '08-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=4),
    (select "student_iid" from "students" where "student_iid"=8),
    '06-01-2020', '08-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=4),
    (select "student_iid" from "students" where "student_iid"=6),
    '06-01-2020', '08-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=4),
    (select "student_iid" from "students" where "student_iid"=4),
    '06-01-2020', '08-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=4),
    (select "student_iid" from "students" where "student_iid"=5),
    '06-01-2020', '08-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=5),
    (select "student_iid" from "students" where "student_iid"=1),
    '06-01-2020', '09-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=5),
    (select "student_iid" from "students" where "student_iid"=2),
    '06-01-2020', '09-02-2020', 'true');
insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
  values( (select "course_iid" from "courses" where "course_iid"=5),
    (select "student_iid" from "students" where "student_iid"=9),
    '06-01-2020', '09-02-2020', 'true');
-- insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
--   values( select "course_iid" from "courses" where "course_iid"=5,
--     select "student_iid" from "students" where "student_iid"=4,
--     '06-01-2020', '09-02-2020', 'true');
-- insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
--   values( (select "course_iid" from "courses" where "course_iid"=2),
--     (select "student_iid" from "students" where "student_iid"=10),
--     '07-02-2020', '07-02-2020', 'true');
-- insert into "enrollments"("course_iid", "student_iid", "enrollment_date", "payment_date", "paid")
--   values( (select "course_iid" from "courses" where "course_iid"=3),
--     (select "student_iid" from "students" where "student_iid"=8),
--     '06-01-2020', '07-02-2020', 'false');
