Port sqlite quotes.db to PostgreSQL

main
Jeffrey Elkner 2 years ago
parent 10b98ad89e
commit 22bf231fa6

1
.gitignore vendored

@ -0,0 +1 @@
.pgenv*

@ -0,0 +1,17 @@
SCRIPTS = $(CURDIR)/scripts
ENV_LOCAL = $(CURDIR)/.pgenv_local
ENV_REMOTE = $(CURDIR)/.pgenv_remote
MAIN = $(SCRIPTS)/create_tables.sql
IMPORT = $(SCRIPTS)/insert_data.sql
SHELL := /usr/bin/env bash
all:
@echo "Error: Please specify remote or local target!"
remote:
source $(ENV_REMOTE) && psql -h $${PGHOST} -d $${PGDATABASE} -U $${PGUSER} -f $(MAIN)
source $(ENV_REMOTE) && psql -h $${PGHOST} -d $${PGDATABASE} -U $${PGUSER} -f $(IMPORT)
local:
source $(ENV_LOCAL) && psql -h $${PGHOST} -d $${PGDATABASE} -U $${PGUSER} -f $(MAIN)
source $(ENV_LOCAL) && psql -h $${PGHOST} -d $${PGDATABASE} -U $${PGUSER} -f $(IMPORT)

@ -1,3 +1,3 @@
# quotesdb # A Database of Quotes
PostgreSQL scripts for a database of quotes. Postgress scripts for a quotes database

@ -0,0 +1,25 @@
BEGIN TRANSACTION;
CREATE TABLE Author(
aid SERIAL PRIMARY KEY,
fname TEXT,
lname TEXT
);
CREATE TABLE Quote(
qid SERIAL PRIMARY KEY,
qtext TEXT,
aid INTEGER,
source TEXT,
qdate DATE,
FOREIGN KEY (aid) REFERENCES Author(aid)
);
CREATE TABLE Category(
cid SERIAL PRIMARY KEY,
description TEXT
);
CREATE TABLE QuoteCategory(
qid INTEGER,
cid INTEGER,
FOREIGN KEY(qid) REFERENCES Quote(qid),
FOREIGN KEY(cid) REFERENCES Category(cid)
);
COMMIT;

@ -0,0 +1,35 @@
BEGIN TRANSACTION;
INSERT INTO Author VALUES(1,'Frederick','Douglas');
INSERT INTO Author VALUES(2,'Abraham','Lincoln');
INSERT INTO Author VALUES(3,'Albert','Einstein');
INSERT INTO Author VALUES(4,'Benjamin','Franklin');
INSERT INTO Author VALUES(5,'Malcolm','X');
INSERT INTO Author VALUES(6,'Hugo','Chavez');
INSERT INTO Author VALUES(7,'Paulo','Friere');
INSERT INTO Quote VALUES(1,'Let me give you a word of the philosophy of reforms. The whole history of the progress of human liberty shows that all concessions yet made to her august claims have been born of struggle... If there is no struggle there is no progress... Power concedes nothing without a demand. It never did and it never will...',1,NULL,NULL);
INSERT INTO Quote VALUES(2,'As I would not be a slave, so I would not be a master. This expresses my idea of democracy.',2,NULL,NULL);
INSERT INTO Quote VALUES(3,'Everything that is really great and inspiring is created by the individual who can labor in freedom.',3,NULL,NULL);
INSERT INTO Quote VALUES(4,'As we enjoy great Advantages from the Inventions of others, we should be glad of an Opportunity to serve others by any Invention of ours, and this we should do freely and generously.',4,NULL,NULL);
INSERT INTO Quote VALUES(5,'I have often reflected upon the new vistas that reading opened to me. I knew right there in prison that reading had changed forever the course of my life. As I see it today, the ability to read awoke in me some long dormant craving to be mentally alive.',5,NULL,NULL);
INSERT INTO Quote VALUES(6,'If knowledge does not have owners, then intellectual property is a trap set by neo-liberalism.',6,NULL,'September 28, 2004');
INSERT INTO Quote VALUES(7,'Education either functions as an instrument which is used to facilitate integration of the younger generation into the logic of the present system and bring about conformity or it becomes the practice of freedom, the means by which men and women deal critically and creatively with reality and discover how to participate in the transformation of their world.',7,'Pedagogy of the Oppressed',NULL);
INSERT INTO Quote VALUES(8,'In our every deliberation, we must consider the impact of our decisions on the next seven generations.',NULL,'The Great Law of The Iroquois Confederacy',NULL);
INSERT INTO Category VALUES(1,'Freedom');
INSERT INTO Category VALUES(2,'Democracy');
INSERT INTO Category VALUES(3,'Sustainability');
INSERT INTO Category VALUES(4,'Education');
INSERT INTO Category VALUES(5,'Politics');
INSERT INTO Category VALUES(6,'Sharing');
INSERT INTO Category VALUES(7,'Knowledge');
INSERT INTO QuoteCategory VALUES(1,1);
INSERT INTO QuoteCategory VALUES(1,5);
INSERT INTO QuoteCategory VALUES(2,1);
INSERT INTO QuoteCategory VALUES(2,2);
INSERT INTO QuoteCategory VALUES(3,1);
INSERT INTO QuoteCategory VALUES(4,6);
INSERT INTO QuoteCategory VALUES(5,4);
INSERT INTO QuoteCategory VALUES(6,7);
INSERT INTO QuoteCategory VALUES(7,1);
INSERT INTO QuoteCategory VALUES(7,4);
INSERT INTO QuoteCategory VALUES(8,3);
COMMIT;
Loading…
Cancel
Save