Jordan Industrial Observatory
Strengthening Industrial Intelligence for enhanced evidence-based policymaking

2. MySQL Data for Production

Shared MySQL instance

For the production Data View/Download screen, data is being fetched from a MySQL database. We are using the same MySQL instance that was installed as part of WordPress. The schema is different (jordanio). The creation and initialization of this database is a one-time process, so it is not covered here. What is given is the schema of the tables used as part of SQL CREATE statements. These commands need to be run within MySQL to create the database schema and tables for a new installation.

CREATE DATABASE IF NOT EXISTS jordanio CHARACTER SET "utf8";
USE jordanio;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS mva;
DROP TABLE IF EXISTS indstat2;
DROP TABLE IF EXISTS indstat4;
CREATE TABLE mva (
	year smallint NOT NULL,
	iso char(3) NOT NULL,
	var varchar(7),
	value bigint NULL,
	PRIMARY KEY (year, iso, var)
);
CREATE TABLE indstat2 (
	year smallint NOT NULL,
	iso char(3) NOT NULL,
	var varchar(3),
	isic2 char(2),
	value bigint,
	PRIMARY KEY (year, iso, var, isic2)
);
CREATE TABLE indstat4 (
	year smallint NOT NULL,
	iso char(3) NOT NULL,
	var varchar(3),
	isic4 char(4),
	value bigint,
	PRIMARY KEY (year, iso, var, isic4)
);
CREATE TABLE indstat4_4 (
	year smallint NOT NULL,
	iso char(3) NOT NULL,
	var varchar(3),
	isic4 char(4),
	value bigint,
	PRIMARY KEY (year, iso, var, isic4)
);
CREATE TABLE users (
	userid varchar(20) NOT NULL DEFAULT "",
	fullname varchar(60) DEFAULT NULL,
	password varchar(8) DEFAULT NULL,
	userlvl smallint(6) DEFAULT NULL,
	PRIMARY KEY (`userid`)
);
CREATE USER jordanio IDENTIFIED BY 'jordaniopwd';
GRANT ALL PRIVILEGES ON jordanio.* TO jordanio;

Once the schema and tables are created, the simplest way to initialize the tables is to run the administrator Data Update operation for UNIDO data (UN Comtrade data is already part of the jordan.zip file, so it does not need to be initialized; the update operation can be run later to bring the trade data up to date).

Leave a Comment

Your email address will not be published.