Code Monkey home page Code Monkey logo

docker-pgadmin's Introduction

Docker compose PGadmin example setup

Quick steps

  1. Install Docker-Compose
  2. Install GIT
  3. Open a terminal
  4. Checkout this repository via git clone https://github.com/ag-gipp/docker-pgadmin.git
  5. Start the containers via docker-compose up -d
  6. Navigate to your local pg-amdin web ui
  7. Log in with the credentials from the docker-compose file
      PGADMIN_DEFAULT_EMAIL: [email protected]
      #Change this password
      PGADMIN_DEFAULT_PASSWORD: MFSYTZVH9HPHL92A
  1. Connect to the database
    1. Click Servers->Create->Server... create_server
    2. In the General tab specify the name server_name
    3. In the Connection tab specify the credentials cerate_server use the password from docker-compose file
    container_name: mondial_db
    ...
      #Change this password
      POSTGRES_PASSWORD: KAKZEHZFP22L3A34

Simple SQL statements

Please find some sample statements below
CREATE TABLE professor (ID Integer, 
    FirstName VARCHAR(50),
    LastName VARCHAR(50),
    Office VARCHAR(50),
    PRIMARY KEY (ID));

CREATE TABLE student (ID Integer, 
    FirstName VARCHAR(50),
    LastName VARCHAR(50),
    PRIMARY KEY (ID));

CREATE TABLE lecture (ID Integer, 
    Title VARCHAR(50),
    Credits Integer,
    Room VARCHAR(50),
    PRIMARY KEY (ID));

CREATE TABLE attends (Student Integer, 
    Lecture Integer,
    FOREIGN KEY (Student) REFERENCES student(ID),
    FOREIGN KEY (Lecture) REFERENCES lecture(ID),
    PRIMARY KEY (Student, Lecture));

CREATE TABLE teaches (Professor Integer, 
    Lecture Integer,
    FOREIGN KEY (Professor) REFERENCES professor(ID),
    FOREIGN KEY (Lecture) REFERENCES lecture(ID),
    PRIMARY KEY (Professor, Lecture));

INSERT INTO professor (ID, FirstName, LastName, Office) 
VALUES (1, 'Julia', 'Maier', 'G12.42');

INSERT INTO lecture (ID, Title, Credits, Room) 
VALUES (1, 'Datenbanken', 6, 'HS10');

INSERT INTO student (ID, FirstName, LastName) 
VALUES (1, 'Max', 'Mustermann');

INSERT INTO teaches (Professor, Lecture) 
VALUES (1, 1);

INSERT INTO attends (Student, Lecture) 
VALUES (1, 1);

-- Contraint Violation (Default NO ACTION)

DELETE FROM lecture WHERE ID = 1;

DELETE FROM professor WHERE ID = 1;

DELETE FROM student WHERE ID = 1;

-- No Contraint Violation (Default NO ACTION)

DELETE FROM attends WHERE Student = 1;
DELETE FROM student WHERE ID = 1;

-- Change attends table to CASCADE (CAREFUL!)

ALTER TABLE attends DROP CONSTRAINT attends_student_fkey;

ALTER TABLE attends ADD CONSTRAINT attends_student_fkey 
FOREIGN KEY (Student) REFERENCES student(ID) 
ON DELETE CASCADE ON UPDATE CASCADE;

-- Update/DELETE (CASCADE)

UPDATE student SET ID=2 WHERE FirstName = 'Max' and LastName='Mustermann';

DELETE FROM student WHERE ID = 2;

Indexes

Please find some sample statements below
SELECT geonameid, asciiname, country
FROM geoname
WHERE name = 'Wuppertal';
-- Cost 6644.81, Time 28.923ms
CREATE INDEX idx_name ON geoname (name);
-- Time 699ms, Size 5328kB
SELECT geonameid, asciiname, country
FROM geoname
WHERE name = 'Wuppertal';
-- Cost 12.45, Time 0.027ms


SELECT geonameid, asciiname, name
FROM geoname
WHERE country = 'DE';
-- Cost 7122.27, Time 54.128 ms
CREATE INDEX idx_country ON geoname (country);
-- Time 309ms, Size 1376 kB
SELECT geonameid, asciiname, name
FROM geoname
WHERE country = 'DE';
-- Cost 522.75, Time 11.403 ms
CLUSTER verbose  geoname using idx_country;
-- 4644 pages, Time 1245 ms
SELECT geonameid, asciiname, name
FROM geoname
WHERE country = 'DE';
-- Cost 522.75, Time 4.475 ms

docker-pgadmin's People

Contributors

physikerwelt avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.