Skip to content

Instantly share code, notes, and snippets.

@ojles
Created September 12, 2018 13:26
Show Gist options
  • Select an option

  • Save ojles/6d7a2d1b637dfc0e73ef13b186990469 to your computer and use it in GitHub Desktop.

Select an option

Save ojles/6d7a2d1b637dfc0e73ef13b186990469 to your computer and use it in GitHub Desktop.

Revisions

  1. ojles created this gist Sep 12, 2018.
    35 changes: 35 additions & 0 deletions postgr
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    * ER diagrams
    * create schema and insert some data
    * postgresql domains
    * constraints
    * indexes

    drop table if exists ad_agency;
    drop table if exists customer;
    drop table if exists advertisement;
    drop table if exists ad_campaign;

    create table ad_agency (
    id serial primary key,
    name varchar(100),
    address varchar(150)
    );

    create table customer (
    id serial primary key,
    agency_id serial references ad_agency(id) on update cascade on delete cascade,
    first_name varchar(50),
    last_name varchar(50),
    email varchar(254),
    phone_number varchar(15)
    );

    create table ad_campaign (
    id serial primary key,
    description text,


    create table advertisement (
    id serial primary key,
    description text,