├── app.js ├── db.js ├── server.js ├── README.md ├── controller.js └── db ├── data_dump.sql └── structure_dump.sql /app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | 4 | var Controller = require('./controller'); 5 | app.use('/greekApi', Controller); 6 | 7 | module.exports = app; 8 | -------------------------------------------------------------------------------- /db.js: -------------------------------------------------------------------------------- 1 | var mysqlApp = require('mysql'); 2 | var connection = mysqlApp.createConnection({ 3 | host : 'xxx', 4 | user: 'xxx', 5 | password: 'xxx', 6 | database: 'greekMythology' 7 | }); 8 | 9 | 10 | connection.connect(); 11 | 12 | module.exports = connection; 13 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | 2 | /*When run as cronjob on boot, better wait some time until mySQL db is done initializing*/ 3 | setTimeout(startServer, 10000); 4 | 5 | 6 | function startServer() { 7 | 8 | var app = require('./app'); 9 | var https = require('https'); 10 | var fs = require('fs'); 11 | var port = process.env.PORT || 443; 12 | 13 | var sslOptions = { 14 | key: fs.readFileSync('/path/to/key'), 15 | cert: fs.readFileSync('/path/to/cert') 16 | }; 17 | 18 | 19 | https.createServer(sslOptions, app).listen(port,function() { 20 | console.log('Express server listerning on port ' + port); 21 | }) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GreekApi :trident: 2 | 3 | This Web API will let you query information from Greek Mythology. Currently features ~150 characters, which is about 5% upon completion. 4 | 5 | ### Commands 6 | This API can be used via HTTP protocol. Send a GET request to any of the paths below. You will receive a JSON response. 7 | 8 | | URL | Description | 9 | | ------ | ------ | 10 | | **/person/\/:name**
lang:
(required)
'de' or 'en'| Retrieve data for specified person| 11 | | **/person/getAll** *\<+params\>*
URL params:
(optional)
lang=[de\|en]
gender=[male\|female] | Retrieve list of all available persons| 12 | | **/person/random** *\<+params\>*
URL params:
(optional)
lang=[de\|en]
gender=[male\|female] | Retrieve random person's data | 13 | | 14 | 15 | #### 1. Examples 16 | 17 | 1.1 Request: Information about Zeus with english localization 18 | 19 | ``https://anfi.tk/greekApi/person/en/Zeus`` 20 | 21 | Response: 22 | ``` 23 | { 24 | "personID": 1, 25 | "name": "zeus", 26 | "mother": { 27 | "personID": 69, 28 | "name": "Rhea" 29 | }, 30 | "father": { 31 | "personID": 70, 32 | "name": "Cronos" 33 | }, 34 | "wife": [ 35 | { 36 | "personID": 67, 37 | "name": "Hera" 38 | } 39 | ], 40 | "son": [ 41 | { 42 | "personID": 29, 43 | "name": "Dionysus" 44 | }, 45 | { 46 | "personID": 40, 47 | "name": "Aeacus" 48 | }, 49 | { 50 | "personID": 60, 51 | "name": "Tantalus" 52 | }, 53 | { 54 | "personID": 66, 55 | "name": "Ares" 56 | }, 57 | { 58 | "personID": 108, 59 | "name": "Heracles" 60 | } 61 | ], 62 | "daughter": [ 63 | { 64 | "personID": 65, 65 | "name": "Aphrodite" 66 | }, 67 | { 68 | "personID": 133, 69 | "name": "Hebe" 70 | } 71 | ], 72 | "status": "OK" 73 | } 74 | ``` 75 | 76 | 1.2 Request: Random female person with german localization 77 | 78 | ``` https://anfi.tk/greekApi/person/random?lang=de&gender=female ``` 79 | 80 | Response: 81 | ``` 82 | { 83 | "personID": 33, 84 | "name": "Krëusa", 85 | "husband": [ 86 | { 87 | "personID": 32, 88 | "name": "Xuthos" 89 | } 90 | ], 91 | "son": [ 92 | { 93 | "personID": 34, 94 | "name": "Ion" 95 | } 96 | ], 97 | "status": "OK" 98 | } 99 | ``` 100 | -------------------------------------------------------------------------------- /controller.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var bodyParser = require('body-parser'); 4 | var db = require('./db'); 5 | router.use(bodyParser.urlencoded({ extended: true})); 6 | 7 | router.get('/person/de/:name', function(req,res) { 8 | getPerson(req.params.name,res,'de'); 9 | }); 10 | 11 | router.get('/person/en/:name', function(req,res) { 12 | getPerson(req.params.name,res,'en'); 13 | }); 14 | router.get('/person/getAll', function(req,res) { 15 | let language_identifier = req.query.lang; 16 | let gender = req.query.gender; 17 | getAll(res, language_identifier, gender); 18 | }); 19 | 20 | router.get('/person/random', function(req,res) { 21 | 22 | let language_identifier = req.query.lang; 23 | let gender = req.query.gender; 24 | getRandomPerson(res, language_identifier, gender); 25 | }); 26 | 27 | function getPerson(user_input,res,language_identifier) { 28 | var p4 = new Promise((resolve, reject) => { 29 | 30 | let query = db.query('SELECT personID FROM person where name_'+language_identifier+' = ?',[user_input], function(err, result) { 31 | if(result.length==0) { 32 | 33 | let respObj = {}; 34 | respObj.error_message = "No person with such name found."; 35 | respObj.status = "PERSON_NOT_FOUND"; 36 | 37 | res.charset = 'UTF-8'; 38 | res.type('application/json'); 39 | res.status(200).send(JSON.stringify(respObj,null,3)); 40 | } 41 | else 42 | resolve(result[0]['personID']); 43 | 44 | }); 45 | 46 | }); 47 | 48 | p4.then((personID) => { 49 | 50 | let p1 = new Promise((resolve, reject) => { 51 | //Retrieve parents - father and mother 52 | let query = db.query('SELECT * FROM CHILD_PARENT_VIEW_'+language_identifier+' WHERE childID = ?', [personID], function(err, result) { 53 | resolve(result); 54 | }) 55 | }); 56 | 57 | let p2 = new Promise((resolve, reject) => { 58 | //Retrieve children - sons and daughters 59 | let query = db.query('SELECT * FROM CHILD_PARENT_VIEW_'+language_identifier+' WHERE parentID = ?',[personID], function(err, result) { 60 | resolve(result); 61 | }) 62 | }); 63 | 64 | 65 | let p3 = new Promise((resolve, reject) => { 66 | //Retrieve siblings - brothers and sisters. Will also yield any half siblings. 67 | db.query('SELECT parentID, parentGender FROM CHILD_PARENT_VIEW_'+language_identifier+' WHERE childID = ?',[personID], function(err, result) { 68 | let fatherID, motherID; 69 | if(result.length!=0) { 70 | for(let parent of result){ 71 | if(parent['parentGender'] == 1) 72 | fatherID = parent['parentID']; 73 | else 74 | motherID = parent['parentID']; 75 | } 76 | } 77 | 78 | db.query('SELECT childID, childGender, childName FROM CHILD_PARENT_VIEW_'+language_identifier+' WHERE (parentID = ? OR parentID = ?) AND childID != ? GROUP BY childID',[fatherID,motherID,personID], function(err, result) { 79 | resolve(result); 80 | }); 81 | }); 82 | 83 | }); 84 | 85 | let p4 = new Promise((resolve, reject) => { 86 | //Retrieve spouse 87 | db.query('SELECT * FROM WIFE_HUSBAND_VIEW_'+language_identifier+' WHERE wifeID = ? OR husbandID = ?',[personID, personID], function (err,result) { 88 | resolve(result); 89 | }); 90 | }); 91 | 92 | Promise.all([p1,p2,p3,p4]).then(values=> { 93 | 94 | let resultParent = values[0]; 95 | let resultChildren = values[1]; 96 | let resultSibling = values[2]; 97 | let resultSpouse = values[3]; 98 | let respObj = {}; //Contains all retrieved relationships 99 | 100 | respObj.personID = personID; 101 | respObj.name = user_input; 102 | //p1: Adding father/mother 103 | if(resultParent.length!=0) { 104 | for(let parent of resultParent ){ 105 | if(parent['parentGender'] == 1) 106 | respObj.father = {"personID":parent['parentID'], "name":parent['parentName']}; 107 | else //Must be mother 108 | respObj.mother = {"personID":parent['parentID'], "name":parent['parentName']}; 109 | } 110 | } 111 | //p4: Adding spouse 112 | if(resultSpouse.length!=0) { 113 | if(resultSpouse[0]['wifeID'] == personID) { //Spouse is a 'husband' 114 | let husbandList = []; 115 | for(let husband of resultSpouse) 116 | husbandList.push({"personID":husband['husbandID'], "name":husband['husband']}); 117 | respObj.husband = husbandList; 118 | } 119 | else {//Spouse is 'wife' 120 | let wifeList = []; 121 | for(let wife of resultSpouse) 122 | wifeList.push({"personID":wife['wifeID'], "name":wife['wife']}); 123 | respObj.wife = wifeList; 124 | } 125 | } 126 | //p2: Adding sons/daughters 127 | if(resultChildren.length!=0) { 128 | let sonList = []; 129 | let daughterList = []; 130 | for(let child of resultChildren ){ 131 | if(child['childGender'] == 1) 132 | sonList.push({"personID":child['childID'], "name":child['childName']}); 133 | else //Must be daughter 134 | daughterList.push({"personID":child['childID'], "name":child['childName']}); 135 | } 136 | if(sonList.length!=0) respObj.son = sonList; 137 | if(daughterList.length!=0) respObj.daughter = daughterList; 138 | } 139 | //p3 Adding siblings 140 | if(resultSibling.length!=0) { 141 | let brotherList = []; 142 | let sisterList = []; 143 | 144 | for(let sibling of resultSibling ){ 145 | if(sibling['childGender'] == 1) 146 | brotherList.push({"personID":sibling['childID'], "name":sibling['childName']}); 147 | else //Must be sister 148 | sisterList.push({"personID":sibling['childID'], "name":sibling['childName']}); 149 | } 150 | if(brotherList.length!=0) respObj.brother = brotherList; 151 | if(sisterList.length!=0) respObj.sister = sisterList; 152 | } 153 | //p6: adding sister(s) 154 | res.charset = 'UTF-8'; 155 | res.type('application/json'); 156 | respObj.status = "OK"; 157 | res.status(200).send(JSON.stringify(respObj,null,3)); 158 | }) 159 | 160 | 161 | }); 162 | } 163 | 164 | function getRandomPerson(res, language_identifier, gender) { 165 | if(!language_identifier) language_identifier = 'en'; //Defaults to english if no language_identifier provided 166 | let sql = 'SELECT ' + db.escapeId('name_' + language_identifier) + ' AS name FROM person '; 167 | if(gender === 'male') sql += 'WHERE gender = 1'; 168 | if(gender === 'female') sql += 'WHERE gender = 2'; 169 | 170 | sql += ' ORDER BY RAND() LIMIT 1'; 171 | 172 | db.query(sql, function(err, result) { 173 | if(err || result.length == 0) { 174 | let respObj = {}; 175 | res.charset = 'UTF-8'; 176 | res.type('application/json'); 177 | respObj.error_message = "Query parameters are invalid."; 178 | respObj.status = "INVALID_PARAMETERS"; 179 | res.status(200).send(JSON.stringify(respObj,null,3)); 180 | } 181 | else getPerson(result[0]['name'], res, language_identifier); 182 | }); 183 | } 184 | function getAll(res, language_identifier, gender) { 185 | if(!language_identifier) language_identifier = 'en'; //Defaults to english if no language_identifier provided 186 | let sql = 'SELECT personID, ' + db.escapeId('name_' + language_identifier) + 'AS name FROM person '; 187 | if(gender === 'male') sql += 'WHERE gender = 1'; 188 | if(gender === 'female') sql += 'WHERE gender = 2'; 189 | 190 | db.query(sql, function(err, result) { 191 | if(err || result.length == 0) res.status(200).send("Invalid query parameters"); 192 | else { 193 | let respObj = {}; //JSON object 194 | let personList = [] //Array 195 | for(let person of result) { 196 | personList.push({"personID":person.personID, "name":person.name}); 197 | } 198 | respObj.persons = personList; 199 | respObj.totalCount = result.length; 200 | res.charset = 'UTF-8'; 201 | res.type('application/json'); 202 | respObj.status = "OK"; 203 | res.status(200).send(JSON.stringify(respObj,null,3)); 204 | 205 | } 206 | }); 207 | } 208 | 209 | module.exports = router; 210 | -------------------------------------------------------------------------------- /db/data_dump.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `greekMythology` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `greekMythology`; 3 | 4 | 5 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 6 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 7 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 8 | /*!40101 SET NAMES utf8 */; 9 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 10 | /*!40103 SET TIME_ZONE='+00:00' */; 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | 16 | -- 17 | -- Dumping data for table `gender` 18 | -- 19 | 20 | LOCK TABLES `gender` WRITE; 21 | /*!40000 ALTER TABLE `gender` DISABLE KEYS */; 22 | INSERT INTO `gender` VALUES (2,'female'),(1,'male'); 23 | /*!40000 ALTER TABLE `gender` ENABLE KEYS */; 24 | UNLOCK TABLES; 25 | 26 | -- 27 | -- Dumping data for table `parentAndChild` 28 | -- 29 | 30 | LOCK TABLES `parentAndChild` WRITE; 31 | /*!40000 ALTER TABLE `parentAndChild` DISABLE KEYS */; 32 | INSERT INTO `parentAndChild` VALUES (29,1),(40,1),(60,1),(65,1),(66,1),(108,1),(133,1),(2,3),(2,4),(147,4),(3,5),(3,6),(2,7),(10,8),(10,9),(12,10),(13,14),(20,14),(21,14),(22,14),(13,15),(20,15),(21,15),(22,15),(8,17),(8,18),(17,18),(17,19),(24,20),(25,20),(26,20),(27,20),(28,20),(24,23),(25,23),(26,23),(27,23),(28,23),(31,24),(38,26),(29,28),(31,30),(34,33),(34,35),(37,36),(38,39),(48,40),(49,40),(50,40),(49,41),(50,41),(48,42),(40,43),(58,49),(57,50),(125,50),(53,51),(53,52),(54,55),(54,56),(58,59),(85,60),(60,61),(62,63),(62,64),(64,65),(64,66),(66,67),(133,67),(65,68),(85,68),(1,69),(1,70),(69,71),(70,71),(69,72),(70,72),(79,78),(80,78),(81,78),(82,78),(83,78),(84,78),(79,85),(80,85),(81,85),(82,85),(83,85),(84,85),(88,86),(88,87),(90,88),(90,89),(93,91),(94,91),(93,92),(94,92),(97,95),(98,95),(97,96),(98,96),(101,99),(104,99),(101,100),(104,100),(103,101),(103,102),(107,105),(108,105),(107,106),(131,108),(132,108),(134,108),(135,108),(139,109),(109,110),(112,111),(113,112),(116,114),(117,114),(116,115),(117,115),(119,118),(120,118),(125,124),(124,126),(127,126),(129,128),(131,130),(132,130),(134,133),(135,133),(137,136),(139,138),(141,140),(144,143),(146,145),(147,146),(149,148),(150,148),(151,148),(149,152),(150,152),(151,152),(154,153),(156,154),(156,155),(158,156),(158,157),(73,159),(73,160); 33 | /*!40000 ALTER TABLE `parentAndChild` ENABLE KEYS */; 34 | UNLOCK TABLES; 35 | 36 | -- 37 | -- Dumping data for table `person` 38 | -- 39 | 40 | LOCK TABLES `person` WRITE; 41 | /*!40000 ALTER TABLE `person` DISABLE KEYS */; 42 | INSERT INTO `person` VALUES (1,'Zeus','Zeus',1),(2,'Bellerophontes','Bellerophon',1),(3,'Glaukos','Glaucus',1),(4,'Poseidon','Poseidon',1),(5,'Sisyphos','Sisyphus',1),(6,'Merope','Merope',2),(7,'Eurynome','Eurynome',2),(8,'Polyneikes','Polynices',1),(9,'Argeia','Argea',2),(10,'Thersandros','Thersander',1),(12,'Teisamenos','Tisamenus',1),(13,'Europa','Europa',2),(14,'Agenor','Agenor',1),(15,'Telephassa','Telephassa',2),(17,'Ödipus','Oedipus',1),(18,'Iokaste','Jocasta',2),(19,'Laios','Laios',1),(20,'Kadmos','Cadmus',1),(21,'Kilix','Cilix',1),(22,'Phoinix','Phoenix',1),(23,'Harmonia','Harmonia',2),(24,'Agaue','Agave',2),(25,'Polydoros','Polydorus',1),(26,'Autonoë','Autonoë',2),(27,'Ino','Ino',2),(28,'Semele','Semele',2),(29,'Dionysos','Dionysus',1),(30,'Echion','Echion',1),(31,'Pentheus','Pentheus',1),(32,'Xuthos','Xuthus',1),(33,'Krëusa','Creusa',2),(34,'Ion','Ion',1),(35,'Apollon','Apollo',1),(36,'Daidalos','Daedalus',1),(37,'Ikarus','Icarus',1),(38,'Aktaion','Actaeon',1),(39,'Aristaios','Aristaeus',1),(40,'Aiakos','Aeacus',1),(41,'Endeïs','Endeïs',2),(42,'Psamathe','Psamathe',2),(43,'Aigina','Aegina',2),(48,'Phokos','Phocus',1),(49,'Peleus','Peleus',1),(50,'Telamon','Telamon',1),(51,'Herse','Herse',2),(52,'Hermes','Hermes',1),(53,'Kephalos','Cephalus',1),(54,'Prokris','Procris',2),(55,'Erechtheus','Erechtheus',1),(56,'Praxithea','Praxithea',2),(57,'Aias','Ajax',1),(58,'Achilleus','Achilles',1),(59,'Thetis','Thetis',2),(60,'Tantalos','Tantalus',1),(61,'Pluto','Plouto',2),(62,'Hedone','Hedone',2),(63,'Psyche','Psyche',2),(64,'Eros','Eros',1),(65,'Aphrodite','Aphrodite',2),(66,'Ares','Ares',1),(67,'Hera','Hera',2),(68,'Dione','Dione',2),(69,'Rhea','Rhea',2),(70,'Kronos','Cronos',1),(71,'Uranos','Uranus',1),(72,'Gaia','Gaia',2),(73,'Leto','Leto',2),(74,'Teiresias','Tiresias',1),(75,'Manto','Manto',2),(77,'Rhakios','Rhacius',1),(78,'Amphion','Amphion',1),(79,'Ismenos','Ismenus',1),(80,'Siphlos','Sipylus',1),(81,'Phaidimos','Phaedimus',1),(82,'Alphenor','Alphenor',1),(83,'Damasichthon','Damasichthon',1),(84,'Ilioneus','Ilioneus',1),(85,'Niobe','Niobe',2),(86,'Hermothoe','Hermothoe',2),(87,'Pandareos','Pandareus',1),(88,'Aëdon','Aedon',2),(89,'Zethos','Zethus',1),(90,'Itylos','Ithylus',1),(91,'Leda','Leda',2),(92,'Tyndareos','Tyndareus',1),(93,'Kastor','Castor',1),(94,'Polydeukes','Polydeuces',1),(95,'Arene','Arene',2),(96,'Aphareus','Aphareus',1),(97,'Lynkeus','Lynceus',1),(98,'Idas','Idas',1),(99,'Asterope','Sterope',2),(100,'Oinomaos','Oenomaus',1),(101,'Alkippe','Alcippe',2),(102,'Euenos','Evenus',1),(103,'Marpessa','Marpessa',2),(104,'Hippodameia','Hippodamia',2),(105,'Alkmene','Alcmene',2),(106,'Amphytrion','Amphytrion',1),(107,'Iphikles','Iphicles',1),(108,'Herakles','Heracles',1),(109,'Megara','Megara',2),(110,'Kreon','Creon',1),(111,'Helios','Helios',1),(112,'Augias','Augeas',1),(113,'Phyleus','Phyleus',1),(114,'Chloris','Chloris',2),(115,'Neleus','Neleus',1),(116,'Periklymenos','Periclymenus',1),(117,'Nestor','Nestor',1),(118,'Eurytos','Eurytos',1),(119,'Iole','Iole',2),(120,'Iphitos','Iphitos',1),(124,'Hesione','Hesione',2),(125,'Teukros','Teucer',1),(126,'Laomedon','Laomedon',1),(127,'Podarkes','Podarces',1),(128,'Syleus','Syleus',1),(129,'Xenodoke','Xenodice',2),(130,'Deïaneira','Deianira',2),(131,'Hyllos','Hyllus',1),(132,'Makaria','Macaria',2),(133,'Hebe','Hebe',2),(134,'Aniketos','Anicetos',1),(135,'Alexiares','Alexiares',1),(136,'Midas','Midas',1),(137,'Lytierses','Lityerses',1),(138,'Iolaos','Iolaus',1),(139,'Leipephile','Leipephilene',2),(140,'Pelias','Pelias',1),(141,'Alkestis','Alcestis',2),(142,'Admetos','Admetus',1),(143,'Oikles','Oecles',1),(144,'Amphiaraos','Amphiaraus',1),(145,'Kerkyon','Cercyon',1),(146,'Alope','Alope',2),(147,'Hippothoon','Hippothoon',1),(148,'Minos','Minos',1),(149,'Phaidra','Phaedra',2),(150,'Androgeos','Androgeos',1),(151,'Ariadne','Ariadne',2),(152,'Pasiphae','Pasiphae',2),(153,'Pittheus','Pittheus',1),(154,'Aithra','Aethra',2),(155,'Aigeus','Aegeus',1),(156,'Theseus','Theseus',1),(157,'Antiope','Antiope',2),(158,'Hippolytos','Hippolytus',1),(159,'Phoibe','Phoebe',2),(160,'Koios','Coeus',1); 43 | /*!40000 ALTER TABLE `person` ENABLE KEYS */; 44 | UNLOCK TABLES; 45 | 46 | -- 47 | -- Dumping data for table `personDescription` 48 | -- 49 | 50 | LOCK TABLES `personDescription` WRITE; 51 | /*!40000 ALTER TABLE `personDescription` DISABLE KEYS */; 52 | INSERT INTO `personDescription` VALUES (2,'Zähmte Pegasus \r Tötete die Chimära \r Versuchte übermütig, den Olymp zu erreichen',NULL); 53 | /*!40000 ALTER TABLE `personDescription` ENABLE KEYS */; 54 | UNLOCK TABLES; 55 | 56 | -- 57 | -- Dumping data for table `wifeAndHusband` 58 | -- 59 | 60 | LOCK TABLES `wifeAndHusband` WRITE; 61 | /*!40000 ALTER TABLE `wifeAndHusband` DISABLE KEYS */; 62 | INSERT INTO `wifeAndHusband` VALUES (67,1),(7,3),(6,5),(9,8),(15,14),(18,17),(18,19),(23,20),(151,29),(24,30),(33,32),(26,39),(41,40),(59,49),(124,50),(51,52),(54,53),(56,55),(63,64),(65,66),(69,70),(72,71),(75,77),(85,78),(86,87),(88,89),(91,92),(95,96),(99,100),(101,102),(109,108),(133,108),(114,115),(119,131),(109,138),(141,142),(152,148),(157,156),(159,160); 63 | /*!40000 ALTER TABLE `wifeAndHusband` ENABLE KEYS */; 64 | UNLOCK TABLES; 65 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 66 | 67 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 68 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 69 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 70 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 71 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 72 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 73 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 74 | 75 | -- Dump completed on 2017-09-22 13:09:46 76 | -------------------------------------------------------------------------------- /db/structure_dump.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `greekMythology` /*!40100 DEFAULT CHARACTER SET latin1 */; 2 | USE `greekMythology`; 3 | 4 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 5 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 6 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 7 | /*!40101 SET NAMES utf8 */; 8 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 9 | /*!40103 SET TIME_ZONE='+00:00' */; 10 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 11 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 12 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 13 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 14 | 15 | -- 16 | -- Temporary view structure for view `CHILD_PARENT_VIEW_de` 17 | -- 18 | 19 | DROP TABLE IF EXISTS `CHILD_PARENT_VIEW_de`; 20 | /*!50001 DROP VIEW IF EXISTS `CHILD_PARENT_VIEW_de`*/; 21 | SET @saved_cs_client = @@character_set_client; 22 | SET character_set_client = utf8; 23 | /*!50001 CREATE VIEW `CHILD_PARENT_VIEW_de` AS SELECT 24 | 1 AS `childID`, 25 | 1 AS `parentID`, 26 | 1 AS `childName`, 27 | 1 AS `parentName`, 28 | 1 AS `childGender`, 29 | 1 AS `parentGender`*/; 30 | SET character_set_client = @saved_cs_client; 31 | 32 | -- 33 | -- Temporary view structure for view `CHILD_PARENT_VIEW_en` 34 | -- 35 | 36 | DROP TABLE IF EXISTS `CHILD_PARENT_VIEW_en`; 37 | /*!50001 DROP VIEW IF EXISTS `CHILD_PARENT_VIEW_en`*/; 38 | SET @saved_cs_client = @@character_set_client; 39 | SET character_set_client = utf8; 40 | /*!50001 CREATE VIEW `CHILD_PARENT_VIEW_en` AS SELECT 41 | 1 AS `childID`, 42 | 1 AS `parentID`, 43 | 1 AS `childName`, 44 | 1 AS `parentName`, 45 | 1 AS `childGender`, 46 | 1 AS `parentGender`*/; 47 | SET character_set_client = @saved_cs_client; 48 | 49 | -- 50 | -- Temporary view structure for view `HUSBAND` 51 | -- 52 | 53 | DROP TABLE IF EXISTS `HUSBAND`; 54 | /*!50001 DROP VIEW IF EXISTS `HUSBAND`*/; 55 | SET @saved_cs_client = @@character_set_client; 56 | SET character_set_client = utf8; 57 | /*!50001 CREATE VIEW `HUSBAND` AS SELECT 58 | 1 AS `personID`, 59 | 1 AS `name_de`, 60 | 1 AS `name_en`, 61 | 1 AS `gender`, 62 | 1 AS `wifeID`, 63 | 1 AS `husbandID`*/; 64 | SET character_set_client = @saved_cs_client; 65 | 66 | -- 67 | -- Temporary view structure for view `PARENT` 68 | -- 69 | 70 | DROP TABLE IF EXISTS `PARENT`; 71 | /*!50001 DROP VIEW IF EXISTS `PARENT`*/; 72 | SET @saved_cs_client = @@character_set_client; 73 | SET character_set_client = utf8; 74 | /*!50001 CREATE VIEW `PARENT` AS SELECT 75 | 1 AS `personID`, 76 | 1 AS `name_de`, 77 | 1 AS `name_en`, 78 | 1 AS `gender`, 79 | 1 AS `childFK`, 80 | 1 AS `parentFK`*/; 81 | SET character_set_client = @saved_cs_client; 82 | 83 | -- 84 | -- Temporary view structure for view `WIFE` 85 | -- 86 | 87 | DROP TABLE IF EXISTS `WIFE`; 88 | /*!50001 DROP VIEW IF EXISTS `WIFE`*/; 89 | SET @saved_cs_client = @@character_set_client; 90 | SET character_set_client = utf8; 91 | /*!50001 CREATE VIEW `WIFE` AS SELECT 92 | 1 AS `personID`, 93 | 1 AS `name_de`, 94 | 1 AS `name_en`, 95 | 1 AS `gender`, 96 | 1 AS `wifeID`, 97 | 1 AS `husbandID`*/; 98 | SET character_set_client = @saved_cs_client; 99 | 100 | -- 101 | -- Temporary view structure for view `WIFE_HUSBAND_VIEW_de` 102 | -- 103 | 104 | DROP TABLE IF EXISTS `WIFE_HUSBAND_VIEW_de`; 105 | /*!50001 DROP VIEW IF EXISTS `WIFE_HUSBAND_VIEW_de`*/; 106 | SET @saved_cs_client = @@character_set_client; 107 | SET character_set_client = utf8; 108 | /*!50001 CREATE VIEW `WIFE_HUSBAND_VIEW_de` AS SELECT 109 | 1 AS `wifeID`, 110 | 1 AS `husbandID`, 111 | 1 AS `wife`, 112 | 1 AS `husband`*/; 113 | SET character_set_client = @saved_cs_client; 114 | 115 | -- 116 | -- Temporary view structure for view `WIFE_HUSBAND_VIEW_en` 117 | -- 118 | 119 | DROP TABLE IF EXISTS `WIFE_HUSBAND_VIEW_en`; 120 | /*!50001 DROP VIEW IF EXISTS `WIFE_HUSBAND_VIEW_en`*/; 121 | SET @saved_cs_client = @@character_set_client; 122 | SET character_set_client = utf8; 123 | /*!50001 CREATE VIEW `WIFE_HUSBAND_VIEW_en` AS SELECT 124 | 1 AS `wifeID`, 125 | 1 AS `husbandID`, 126 | 1 AS `wife`, 127 | 1 AS `husband`*/; 128 | SET character_set_client = @saved_cs_client; 129 | 130 | -- 131 | -- Table structure for table `gender` 132 | -- 133 | 134 | DROP TABLE IF EXISTS `gender`; 135 | /*!40101 SET @saved_cs_client = @@character_set_client */; 136 | /*!40101 SET character_set_client = utf8 */; 137 | CREATE TABLE `gender` ( 138 | `genderID` int(11) NOT NULL AUTO_INCREMENT, 139 | `gender` varchar(45) NOT NULL, 140 | PRIMARY KEY (`genderID`), 141 | UNIQUE KEY `gender_UNIQUE` (`gender`) 142 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; 143 | /*!40101 SET character_set_client = @saved_cs_client */; 144 | 145 | -- 146 | -- Table structure for table `parentAndChild` 147 | -- 148 | 149 | DROP TABLE IF EXISTS `parentAndChild`; 150 | /*!40101 SET @saved_cs_client = @@character_set_client */; 151 | /*!40101 SET character_set_client = utf8 */; 152 | CREATE TABLE `parentAndChild` ( 153 | `childFK` int(11) NOT NULL, 154 | `parentFK` int(11) NOT NULL, 155 | PRIMARY KEY (`childFK`,`parentFK`), 156 | KEY `parent_fk_idx` (`parentFK`), 157 | CONSTRAINT `child_fk` FOREIGN KEY (`childFK`) REFERENCES `person` (`personID`) ON DELETE CASCADE ON UPDATE CASCADE, 158 | CONSTRAINT `parent_fk` FOREIGN KEY (`parentFK`) REFERENCES `person` (`personID`) ON DELETE CASCADE ON UPDATE CASCADE 159 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 160 | /*!40101 SET character_set_client = @saved_cs_client */; 161 | 162 | -- 163 | -- Table structure for table `person` 164 | -- 165 | 166 | DROP TABLE IF EXISTS `person`; 167 | /*!40101 SET @saved_cs_client = @@character_set_client */; 168 | /*!40101 SET character_set_client = utf8 */; 169 | CREATE TABLE `person` ( 170 | `personID` int(11) NOT NULL AUTO_INCREMENT, 171 | `name_de` varchar(45) NOT NULL, 172 | `name_en` varchar(45) DEFAULT NULL, 173 | `gender` int(11) DEFAULT '1', 174 | PRIMARY KEY (`personID`), 175 | UNIQUE KEY `name_ger_UNIQUE` (`name_de`), 176 | UNIQUE KEY `name_eng_UNIQUE` (`name_en`), 177 | KEY `gender_fk_idx` (`gender`), 178 | CONSTRAINT `gender_fk` FOREIGN KEY (`gender`) REFERENCES `gender` (`genderID`) ON DELETE NO ACTION ON UPDATE CASCADE 179 | ) ENGINE=InnoDB AUTO_INCREMENT=161 DEFAULT CHARSET=latin1; 180 | /*!40101 SET character_set_client = @saved_cs_client */; 181 | 182 | -- 183 | -- Table structure for table `personDescription` 184 | -- 185 | 186 | DROP TABLE IF EXISTS `personDescription`; 187 | /*!40101 SET @saved_cs_client = @@character_set_client */; 188 | /*!40101 SET character_set_client = utf8 */; 189 | CREATE TABLE `personDescription` ( 190 | `personFK` int(11) NOT NULL, 191 | `desc_de` text, 192 | `desc_en` text, 193 | PRIMARY KEY (`personFK`), 194 | UNIQUE KEY `personFK_UNIQUE` (`personFK`), 195 | CONSTRAINT `FK__personDescription__person` FOREIGN KEY (`personFK`) REFERENCES `person` (`personID`) ON DELETE CASCADE ON UPDATE CASCADE 196 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 197 | /*!40101 SET character_set_client = @saved_cs_client */; 198 | 199 | -- 200 | -- Table structure for table `wifeAndHusband` 201 | -- 202 | 203 | DROP TABLE IF EXISTS `wifeAndHusband`; 204 | /*!40101 SET @saved_cs_client = @@character_set_client */; 205 | /*!40101 SET character_set_client = utf8 */; 206 | CREATE TABLE `wifeAndHusband` ( 207 | `wifeID` int(11) NOT NULL, 208 | `husbandID` int(11) NOT NULL, 209 | PRIMARY KEY (`wifeID`,`husbandID`), 210 | KEY `husband_fk_idx` (`husbandID`), 211 | KEY `wifeID_UNIQUE` (`wifeID`), 212 | CONSTRAINT `husband_fk` FOREIGN KEY (`husbandID`) REFERENCES `person` (`personID`) ON DELETE CASCADE ON UPDATE CASCADE, 213 | CONSTRAINT `wife_fk` FOREIGN KEY (`wifeID`) REFERENCES `person` (`personID`) ON DELETE CASCADE ON UPDATE CASCADE 214 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 215 | /*!40101 SET character_set_client = @saved_cs_client */; 216 | 217 | -- 218 | -- Final view structure for view `CHILD_PARENT_VIEW_de` 219 | -- 220 | 221 | /*!50001 DROP VIEW IF EXISTS `CHILD_PARENT_VIEW_de`*/; 222 | /*!50001 SET @saved_cs_client = @@character_set_client */; 223 | /*!50001 SET @saved_cs_results = @@character_set_results */; 224 | /*!50001 SET @saved_col_connection = @@collation_connection */; 225 | /*!50001 SET character_set_client = utf8 */; 226 | /*!50001 SET character_set_results = utf8 */; 227 | /*!50001 SET collation_connection = utf8_general_ci */; 228 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 229 | 230 | /*!50001 VIEW `CHILD_PARENT_VIEW_de` AS select `parentAndChild`.`childFK` AS `childID`,`parentAndChild`.`parentFK` AS `parentID`,`t1`.`name_de` AS `childName`,`t2`.`name_de` AS `parentName`,`t1`.`gender` AS `childGender`,`t2`.`gender` AS `parentGender` from ((`parentAndChild` join `person` `t1` on((`parentAndChild`.`childFK` = `t1`.`personID`))) join `person` `t2` on((`parentAndChild`.`parentFK` = `t2`.`personID`))) */; 231 | /*!50001 SET character_set_client = @saved_cs_client */; 232 | /*!50001 SET character_set_results = @saved_cs_results */; 233 | /*!50001 SET collation_connection = @saved_col_connection */; 234 | 235 | -- 236 | -- Final view structure for view `CHILD_PARENT_VIEW_en` 237 | -- 238 | 239 | /*!50001 DROP VIEW IF EXISTS `CHILD_PARENT_VIEW_en`*/; 240 | /*!50001 SET @saved_cs_client = @@character_set_client */; 241 | /*!50001 SET @saved_cs_results = @@character_set_results */; 242 | /*!50001 SET @saved_col_connection = @@collation_connection */; 243 | /*!50001 SET character_set_client = utf8 */; 244 | /*!50001 SET character_set_results = utf8 */; 245 | /*!50001 SET collation_connection = utf8_general_ci */; 246 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 247 | 248 | /*!50001 VIEW `CHILD_PARENT_VIEW_en` AS select `parentAndChild`.`childFK` AS `childID`,`parentAndChild`.`parentFK` AS `parentID`,`t1`.`name_en` AS `childName`,`t2`.`name_en` AS `parentName`,`t1`.`gender` AS `childGender`,`t2`.`gender` AS `parentGender` from ((`parentAndChild` join `person` `t1` on((`parentAndChild`.`childFK` = `t1`.`personID`))) join `person` `t2` on((`parentAndChild`.`parentFK` = `t2`.`personID`))) */; 249 | /*!50001 SET character_set_client = @saved_cs_client */; 250 | /*!50001 SET character_set_results = @saved_cs_results */; 251 | /*!50001 SET collation_connection = @saved_col_connection */; 252 | 253 | -- 254 | -- Final view structure for view `HUSBAND` 255 | -- 256 | 257 | /*!50001 DROP VIEW IF EXISTS `HUSBAND`*/; 258 | /*!50001 SET @saved_cs_client = @@character_set_client */; 259 | /*!50001 SET @saved_cs_results = @@character_set_results */; 260 | /*!50001 SET @saved_col_connection = @@collation_connection */; 261 | /*!50001 SET character_set_client = utf8 */; 262 | /*!50001 SET character_set_results = utf8 */; 263 | /*!50001 SET collation_connection = utf8_general_ci */; 264 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 265 | 266 | /*!50001 VIEW `HUSBAND` AS select `person`.`personID` AS `personID`,`person`.`name_de` AS `name_de`,`person`.`name_en` AS `name_en`,`person`.`gender` AS `gender`,`wifeAndHusband`.`wifeID` AS `wifeID`,`wifeAndHusband`.`husbandID` AS `husbandID` from (`person` join `wifeAndHusband` on((`person`.`personID` = `wifeAndHusband`.`husbandID`))) */; 267 | /*!50001 SET character_set_client = @saved_cs_client */; 268 | /*!50001 SET character_set_results = @saved_cs_results */; 269 | /*!50001 SET collation_connection = @saved_col_connection */; 270 | 271 | -- 272 | -- Final view structure for view `PARENT` 273 | -- 274 | 275 | /*!50001 DROP VIEW IF EXISTS `PARENT`*/; 276 | /*!50001 SET @saved_cs_client = @@character_set_client */; 277 | /*!50001 SET @saved_cs_results = @@character_set_results */; 278 | /*!50001 SET @saved_col_connection = @@collation_connection */; 279 | /*!50001 SET character_set_client = utf8 */; 280 | /*!50001 SET character_set_results = utf8 */; 281 | /*!50001 SET collation_connection = utf8_general_ci */; 282 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 283 | 284 | /*!50001 VIEW `PARENT` AS select `person`.`personID` AS `personID`,`person`.`name_de` AS `name_de`,`person`.`name_en` AS `name_en`,`person`.`gender` AS `gender`,`parentAndChild`.`childFK` AS `childFK`,`parentAndChild`.`parentFK` AS `parentFK` from (`person` join `parentAndChild` on((`person`.`personID` = `parentAndChild`.`parentFK`))) */; 285 | /*!50001 SET character_set_client = @saved_cs_client */; 286 | /*!50001 SET character_set_results = @saved_cs_results */; 287 | /*!50001 SET collation_connection = @saved_col_connection */; 288 | 289 | -- 290 | -- Final view structure for view `WIFE` 291 | -- 292 | 293 | /*!50001 DROP VIEW IF EXISTS `WIFE`*/; 294 | /*!50001 SET @saved_cs_client = @@character_set_client */; 295 | /*!50001 SET @saved_cs_results = @@character_set_results */; 296 | /*!50001 SET @saved_col_connection = @@collation_connection */; 297 | /*!50001 SET character_set_client = utf8 */; 298 | /*!50001 SET character_set_results = utf8 */; 299 | /*!50001 SET collation_connection = utf8_general_ci */; 300 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 301 | 302 | /*!50001 VIEW `WIFE` AS select `person`.`personID` AS `personID`,`person`.`name_de` AS `name_de`,`person`.`name_en` AS `name_en`,`person`.`gender` AS `gender`,`wifeAndHusband`.`wifeID` AS `wifeID`,`wifeAndHusband`.`husbandID` AS `husbandID` from (`person` join `wifeAndHusband` on((`person`.`personID` = `wifeAndHusband`.`wifeID`))) */; 303 | /*!50001 SET character_set_client = @saved_cs_client */; 304 | /*!50001 SET character_set_results = @saved_cs_results */; 305 | /*!50001 SET collation_connection = @saved_col_connection */; 306 | 307 | -- 308 | -- Final view structure for view `WIFE_HUSBAND_VIEW_de` 309 | -- 310 | 311 | /*!50001 DROP VIEW IF EXISTS `WIFE_HUSBAND_VIEW_de`*/; 312 | /*!50001 SET @saved_cs_client = @@character_set_client */; 313 | /*!50001 SET @saved_cs_results = @@character_set_results */; 314 | /*!50001 SET @saved_col_connection = @@collation_connection */; 315 | /*!50001 SET character_set_client = utf8 */; 316 | /*!50001 SET character_set_results = utf8 */; 317 | /*!50001 SET collation_connection = utf8_general_ci */; 318 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 319 | 320 | /*!50001 VIEW `WIFE_HUSBAND_VIEW_de` AS select `WIFE`.`personID` AS `wifeID`,`HUSBAND`.`personID` AS `husbandID`,`WIFE`.`name_de` AS `wife`,`HUSBAND`.`name_de` AS `husband` from (`WIFE` join `HUSBAND` on((`WIFE`.`personID` = `HUSBAND`.`wifeID`))) where (`WIFE`.`husbandID` = `HUSBAND`.`husbandID`) */; 321 | /*!50001 SET character_set_client = @saved_cs_client */; 322 | /*!50001 SET character_set_results = @saved_cs_results */; 323 | /*!50001 SET collation_connection = @saved_col_connection */; 324 | 325 | -- 326 | -- Final view structure for view `WIFE_HUSBAND_VIEW_en` 327 | -- 328 | 329 | /*!50001 DROP VIEW IF EXISTS `WIFE_HUSBAND_VIEW_en`*/; 330 | /*!50001 SET @saved_cs_client = @@character_set_client */; 331 | /*!50001 SET @saved_cs_results = @@character_set_results */; 332 | /*!50001 SET @saved_col_connection = @@collation_connection */; 333 | /*!50001 SET character_set_client = utf8 */; 334 | /*!50001 SET character_set_results = utf8 */; 335 | /*!50001 SET collation_connection = utf8_general_ci */; 336 | /*!50001 CREATE ALGORITHM=UNDEFINED */ 337 | 338 | /*!50001 VIEW `WIFE_HUSBAND_VIEW_en` AS select `WIFE`.`personID` AS `wifeID`,`HUSBAND`.`personID` AS `husbandID`,`WIFE`.`name_en` AS `wife`,`HUSBAND`.`name_en` AS `husband` from (`WIFE` join `HUSBAND` on((`WIFE`.`personID` = `HUSBAND`.`wifeID`))) where (`WIFE`.`husbandID` = `HUSBAND`.`husbandID`) */; 339 | /*!50001 SET character_set_client = @saved_cs_client */; 340 | /*!50001 SET character_set_results = @saved_cs_results */; 341 | /*!50001 SET collation_connection = @saved_col_connection */; 342 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 343 | 344 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 345 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 346 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 347 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 348 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 349 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 350 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 351 | 352 | -- Dump completed on 2017-09-22 13:08:57 353 | --------------------------------------------------------------------------------