examples/sql/transp.sql
author Alpar Juttner <alpar@cs.elte.hu>
Sun, 05 Dec 2010 17:35:23 +0100
changeset 2 4c8956a7bdf4
permissions -rw-r--r--
Set up CMAKE build environment
alpar@1
     1
CREATE DATABASE glpk;
alpar@1
     2
CREATE USER glpk@localhost IDENTIFIED BY 'gnu';
alpar@1
     3
GRANT ALL PRIVILEGES ON glpk.* TO glpk@localhost;
alpar@1
     4
USE glpk;
alpar@1
     5
# production capacity
alpar@1
     6
DROP TABLE transp_capa;
alpar@1
     7
CREATE TABLE transp_capa (
alpar@1
     8
  PLANT TEXT(127),
alpar@1
     9
  CAPA  REAL,
alpar@1
    10
  PRIMARY KEY ( PLANT(127) )
alpar@1
    11
  );
alpar@1
    12
INSERT INTO transp_capa ( PLANT, CAPA ) VALUES ( 'Seattle',   350 );
alpar@1
    13
INSERT INTO transp_capa ( PLANT, CAPA ) VALUES ( 'San Diego', 600 );
alpar@1
    14
# demand
alpar@1
    15
DROP TABLE transp_demand;
alpar@1
    16
CREATE TABLE transp_demand (
alpar@1
    17
  MARKET TEXT(127),
alpar@1
    18
  DEMAND REAL,
alpar@1
    19
  PRIMARY KEY ( MARKET(127) )
alpar@1
    20
  );
alpar@1
    21
INSERT INTO transp_demand ( MARKET, DEMAND ) VALUES ( 'New York', 325 );
alpar@1
    22
INSERT INTO transp_demand ( MARKET, DEMAND ) VALUES ( 'Chicago', 300 );
alpar@1
    23
INSERT INTO transp_demand ( MARKET, DEMAND ) VALUES ( 'Topeka', 275 );
alpar@1
    24
# distance
alpar@1
    25
DROP TABLE transp_dist;
alpar@1
    26
CREATE TABLE transp_dist (
alpar@1
    27
  LOC1 TEXT(127),
alpar@1
    28
  LOC2 TEXT(127),
alpar@1
    29
  DIST REAL,
alpar@1
    30
  PRIMARY KEY ( LOC1(127), LOC2(127) )
alpar@1
    31
  );
alpar@1
    32
INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'Seattle',   'New York', 2.5 );
alpar@1
    33
INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'Seattle',   'Chicago', 1.7 );
alpar@1
    34
INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'Seattle',   'Topeka', 1.8 );
alpar@1
    35
INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'San Diego', 'New York', 2.5 );
alpar@1
    36
INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'San Diego', 'Chicago', 1.8 );
alpar@1
    37
INSERT INTO transp_dist ( LOC1, LOC2, DIST ) VALUES ( 'San Diego', 'Topeka', 1.4 );
alpar@1
    38
# result
alpar@1
    39
DROP TABLE transp_result;
alpar@1
    40
CREATE TABLE transp_result (
alpar@1
    41
  LOC1     TEXT(127),
alpar@1
    42
  LOC2     TEXT(127),
alpar@1
    43
  QUANTITY REAL,
alpar@1
    44
  PRIMARY KEY ( LOC1(127), LOC2(127) )
alpar@1
    45
  );