Skip to content
Snippets Groups Projects
Commit 0480dfa9 authored by Dan Suciu's avatar Dan Suciu
Browse files

cleanup

parent 851295af
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 5850 deletions
This diff is collapsed.
create table Pub (k text, p text);
create table Field (k text, i text, p text, v text);
copy Pub from 'pubFile.txt';
copy Field from 'fieldFile.txt';
#!/usr/bin/python
import psycopg2
def main():
try:
conn = psycopg2.connect("dbname='dblp' user='<YOUR USER NAME>' host='localhost' password=''")
except psycopg2.Error, e:
print "I am unable to connect to the database"
cur = conn.cursor()
cur.execute("SELECT * FROM author LIMIT 10")
rows = cur.fetchall()
print "Showing first 10 results:\n"
for row in rows:
print row[0], row[1]
if __name__ == "__main__":
main()
import xml.sax
import re
class DBLPContentHandler(xml.sax.ContentHandler):
"""
Reads the dblp.xml file and produces two output files.
pubFile.txt = (key, pubtype) tuples
fieldFile.txt = (key, fieldCnt, field, value) tuples
Each file is tab-separated
Once the program finishes, load these two files in a relational database; run createSchema.sql
"""
def __init__(self):
xml.sax.ContentHandler.__init__(self)
def startElement(self, name, attrs):
if name == "dblp":
DBLPContentHandler.pubFile = open('pubFile.txt', 'w')
DBLPContentHandler.fieldFile = open('fieldFile.txt', 'w')
DBLPContentHandler.pubList = ["article", "inproceedings", "proceedings", "book", "incollection", "phdthesis", "mastersthesis", "www"]
DBLPContentHandler.fieldList = ["author", "editor", "title", "booktitle", "pages", "year", "address", "journal", "volume", "number", "month", "url", "ee", "cdrom", "cite", "publisher", "note", "crossref", "isbn", "series", "school", "chapter"]
DBLPContentHandler.content = ""
if name in DBLPContentHandler.pubList:
DBLPContentHandler.key = attrs.getValue("key")
DBLPContentHandler.pub = name
DBLPContentHandler.fieldCount = 0
DBLPContentHandler.content = ""
if name in DBLPContentHandler.fieldList:
DBLPContentHandler.field = name
DBLPContentHandler.content = ""
def endElement(self, name):
if name in DBLPContentHandler.fieldList:
DBLPContentHandler.fieldFile.write(DBLPContentHandler.key)
DBLPContentHandler.fieldFile.write("\t")
DBLPContentHandler.fieldFile.write(str(DBLPContentHandler.fieldCount))
DBLPContentHandler.fieldFile.write( "\t")
DBLPContentHandler.fieldFile.write(DBLPContentHandler.field)
DBLPContentHandler.fieldFile.write("\t")
DBLPContentHandler.fieldFile.write(DBLPContentHandler.content)
DBLPContentHandler.fieldFile.write("\n")
DBLPContentHandler.fieldCount += 1
if name in DBLPContentHandler.pubList:
DBLPContentHandler.pubFile.write(DBLPContentHandler.key)
DBLPContentHandler.pubFile.write("\t")
DBLPContentHandler.pubFile.write(DBLPContentHandler.pub)
DBLPContentHandler.pubFile.write("\n")
def characters(self, content):
DBLPContentHandler.content += content.replace('\\','\\\\')
def main(sourceFileName):
source = open(sourceFileName)
xml.sax.parse(source, DBLPContentHandler())
if __name__ == "__main__":
main("dblp.xml")
put your .sql files in this directory, one file per question.
File deleted
File deleted
# CSE 544 Homework 2: Finding the Mitochondrial Eve
**Objectives:**
To understand how queries are translated into the relational algebra. To master writing relational queries in a logic formalism using datalog.
**Assignment tools:**
Part 1: pen and paper; Part 2: Soufflé
**Assigned date:** January 21st, 2018
**Due date:** February 2nd, 2018
**What to turn in:** Put the following files in the `submission` folder: `hw2-q1.txt`, `hw2-q2.txt`, `hw2-q3.dl` along with its output `hw2-q3-1.ans`, `hw2-q3-2.ans`, `hw2-q3-3.ans`, `hw2-q3-4.ans`, `hw2-q3-5.ans`(see details below)
**Resources:**
- Soufflé (https://github.com/souffle-lang/souffle)
- Soufflé [language documentation](http://souffle-lang.org/docs/datalog/)
- [Soufflé tutorial](http://souffle-lang.org/pdf/SoufflePLDITutorial.pdf)
- Starter code in your personal repo for Part 2.
- General information for Part 2:
- The [Mitochondrial Eve](https://en.wikipedia.org/wiki/Mitochondrial_Eve)
- List of [women in the Bible](https://en.wikipedia.org/wiki/List_of_women_in_the_Bible)
- List of [minor biblical figures](https://en.wikipedia.org/wiki/List_of_minor_biblical_figures,_A%E2%80%93K)
- Note that the parent-child relationship is randomly generated and may change.
## Assignment Details
### Part 1: Warm Up with Relational Algebra
1. (10 points) Write the equivalent SQL query to this [relational algebra plan](figs/ra.pdf "Relational Algebra Plan"). Save your answer in `hw2-q1.txt`.
2. (10 points) Write a relational algebra plan for the following SQL query:
```sql
select a.p
from person_living a, male b
where a.p = b.name and
not exists (select *
from parent_child c, female d
where c.p1=d.name and c.p2=a.p)
```
You do not need to draw the query plan as a tree and can use the linear style instead. To make precedence clear, we ask you to break down your query plan by using *at most one* operator on each line. For example, given the query in question 1, you could write it as:
```sh
T1(x,p1,p2) = person_living(x) Join[x=p1] parent_child(p1,p2)
T2(p3,p4) = rename[p3,p4] parent_child(p3,p4)
T3(x,p1,p2,p3,p4) = T1(x,p1,p2) Join[p2=p3] T2(p3,p4)
T4(p1,p2,y) = GroupBy[p1,p2,count(*)->y] T3(x,p1,p2,p3,p4)
T5(p1,z) = GroupBy[p1,max(y)->z] T4(p1,p2,y)
```
where `T1`, `T2`, etc are temporary relations. Note that each line has at most one relational operator. You do not need to use the Greek symbols if you prefer. You also don't need to distinguish among the different flavors of join (just make sure that you write out the full join predicate).
Save your answer in `hw2-q2.txt`.
### Part 2. Finding the Mitochondrial Eve
Every human has a mother, who had her own mother, who in turn had her own mother. The matrilineal ancestor of an individual consists of the mother, the mother’s mother, and so on, following only the female lineage. A matrilinial common ancestor, MCA, is a matrilinial ancestor of all living humans. An MCA is very, very likely to exist (why?), and in fact there are many MCAs. The matrilineal most recent ancestor, or MRCA, is the only individual (woman) who is the MCA of all living humans and is the most recent such. Who is she? When did she live? In the 1980s three researchers, Cann, Stoneking and Wilson, analyzed the mitocondrial DNA of living humans and determined that the MRCA lived about 200,000 years ago. The researchers called her the [Mithcondrial Eve](https://en.wikipedia.org/wiki/Mitochondrial_Eve).
In this homework, you will analyze a database of 800 individuals, compute several things, culminating with the the computation of the Mithocondrial Eve. The genealogy database consists of over 800 biblical names, obtained from Wikipedia, with a randomly generated parent-child relationship.
### Getting Started
1. Install Soufflé
1. **Mac user**
* Download the [souffle-1.2.0.pkg](https://github.com/souffle-lang/souffle/releases/tag/1.2.0)
2. **Windows user**
* To ease the installation process, we recommand using the pre-built version of Soufflé on Debian
* Download the [VMPlayer](https://my.vmware.com/en/web/vmware/free#desktop_end_user_computing/vmware_workstation_player/12_0)
* Download the [Debian Image](https://www.debian.org/distrib/netinst). Make sure you install the amd64 version.
* When VMplayer starts running, click on the "Open a Virtual Machine" link. Navigate to the folder where you sotre the Debian Image. Click "OK". Then click on the left-side tab that appears containing the VM name. Click "Play virtual machine".
* When Debian is setup, obtain the pre-built package [souffle_1.2.0-1_amd64.deb](https://github.com/souffle-lang/souffle/releases/tag/1.2.0)
* Open a terminal and navigate to the location where you downloaded the package (which is probably `~/Downloads`)
* Then type `sudo apt install ./souffle_1.2.0-1_amd64.deb`
2. Verify Soufflé is working:
```
$ cd hw2/starter-code
$ souffle hw2-q3.dl
```
Congratulations! You just ran your first datalog query.
### Questions
For each question below, write in the file `hw2-q3.dl` a program that computes the answer to that question. See the Example section below.
1. (10 points) Find all descendants of Priscilla and their descriptions. Name your predicate `p1(x,d)`. Write the output to a file called `hw2-q3-1.ans`(123 rows)
2. (10 points) Find the woman/women with the largest number of children and the man/men with the largest number of children. For each individual, you should return the name of that individual, his/her description, and the number of children. Name your predicate `p2(x,d,n)`. Write the output to a file called `hw2-q3-2.ans`(2 rows)
3. (20 points) For each person x, we call a "complete lineage" any sequence x0=x, x1, x2, … , xn where each person is the parent of the previous person, and the last person has no parents; the length of the sequence is n. If x has a complete lineage of length n, then we also say that "x is in generation n". Compute the minimum and maximum generation of each living person x.
Name your predicate `p3(x,m1,m2)`, where x is a living person, and `m1`, `m2` are the minimal/maximal generation. (Hint: You may want to first compute all generations for all x: think about when can you say that x is in generation 0, and when can you say that x is in generation n+1. Of course x can be in multiple generations, e.g., x's mother is in generation 0 and x's father is in generation 2. Once you know everybody's generations, you can answer the problem easily.) Write the output to a file called `hw2-q3-3.ans` (22 rows)
4. (20 points) Compute all matrilineal common ancestors, MCA. Name your predicate `p4(x)`. Write the output to a file called `hw2-q3-4.ans` (6 rows)
5. (20 points) Find the mitochondrial Eve. Name your predicate `p5(x)`. Remember that you can utilize your predicates defined earlier. Write the output to a file called `hw2-q3-5.ans` (1 row)
#### Example
For example, suppose the question were: find all children of Priscilla; return their names and their descriptions. Then you write this in the `hw3-q3.dl` file (it’s already there):
```c
.output p0(IO=stdout)
p0(x,d) :- parent_child("Priscilla",x), person(x,d). //NOTE the period at the end
```
## Submission Instructions
For Part 1, write your answers in a file `hw2-q1.txt`, and `hw2-q2.txt` and put them in the `submission` folder.
For part 2, write your answers in the provided file `hw2-q3.dl` and name the output generated from p1, p2, p3, p4, p5: `hw2-q3-1.ans`, `hw2-q3-2.ans`, `hw2-q3-3.ans`, `hw2-q3-4.ans`, `hw2-q3-5.ans` and put them in the `submission` folder.
**Important**: To remind you, in order for your answers to be added to the git repo,
you need to explicitly add each file:
```sh
$ git add *.txt *.ans
```
**Again, just because your code has been committed on your local machine does not mean that it has been
submitted -- it needs to be on GitLab!**
Use the same bash script `turnInHw.sh` in the root level directory of your repository that
commits your changes, deletes any prior tag for the current lab, tags the current commit,
and pushes the branch and tag to GitLab.
If you are using Linux or Mac OSX, you should be able to run the following:
```sh
$ ./turnInHw.sh hw2
```
Like previous assignments, make sure you check the results afterwards to make sure that your file(s)
have been committed.
Leah
Mahlah #2
Mahlah #1
Abital
Milcah #2
Milcah #1
Jehudijah
Matred
Jerusha
Noah
Hammolekheth
Athaliah
Achsah (or Acsah)
Queen Vashti
Mahalath #1
Deborah #2
Meshullemeth
Abishag
Timnah (or Timna)
Zillah #2
Elisabeth
Lois, grandmother of Saint Timothy. II Timothy[101]
Aholibamah (or Oholibamah)
Naomi
Eglah
Abigail #4
Abigail #3
Haggith
Rhoda
Lo-Ruhamah
Zilpah
Jehosheba (or Jehoshebeath/Josaba)
Jemima
Helah
Maacah
Asenath
Jerusha #2
Eve
Zillah
Abihail #2
Abihail #1
Hagar
Michal
Mahalath
Susanna #1
Susanna #2
Shiphrah
Tamar #3
Jemima #2
Rizpah
Zipporah
Jehoaddan
Antiochus
Azubah #1
Azubah #2
Delilah
Deborah #1
Medium of En Dor
Zeresh
Baara
Adah
Mehetabeel
Merab #2
Mehetabel #2
Jezebel #1
Jezebel #2
Esther (also known as Hadassah)
Baara #2
Orpah
Martha
Keziah
Salome #2
Salome #1
Mehetabel
Rebekah
Lo–Ruhamah
Reumah
Bathsheba
Jezebel
Basemeth #1
Basemeth #3
Basemeth #2
Tirzah
Puah
Euodia
Hushim #2
Damaris. Acts[41]
Naamah #2
Hannah
Syntyche
Me-Zahab
Mahalath #2
Diblaim
Miriam #1
Keziah #2
Miriam #2
Shelomith
Ephrath
Jael
Ahlai #1
Ahlai #2
Noadiah
Tabitha (Acts 9:36)
Taphath
Cozbi
Tamar #1
Tamar #2
Elisheba #2
Jehoaddan (or Jehoaddin)
Rahab
Elisheba
Hogla (or Hoglah)
Mary #1
Mary #3
Mary #2
Mary #5
Mary #4
Mary #6
Dinah
Taphath #2
Phoebe
Junia or Junias
Iscah
Priscilla
Ahinoam #2
Ahinoam #1
Naarah
Hodiah's wife
Mahlah
Lydia of Thyatira
Hephziba
Shelomit #1
Basemath
Shelomit #2
Jecholiah (or Jecoliah)
Reumah #2
Rachel
Jerioth #2
Jochebed
Atarah
Persis
Merab
Matred #2
Anah
Jerioth
Claudia #2
Julia
Maacah #2
Iscah #2
Judith
Hazelelponi (or Hazzelelponi)
Eunice
Bithiah
Nehushta
Sarah #2
Jecholiah
Sarah #1
Dorcas, also known as Tabitha. Acts[46]
Julia #2
Anna the Prophetess
Keren–Happuch
Claudia
Candace
Sheerah
Huldah
Keturah
Jedidah
Eglah #2
Adah # 1
Adah #2
Gomer
Ruth
Hodesh
Peninnah
Joanna
Ephah
Hamutal
Bilhah
Sapphira
Zeruiah
Hodesh #2
Naamah #1
Persian 'مهمان signifies a stranger or guest' [17] Melatiah
Ethnan
Ibneiah
Iphdeiah
Bidkar
Elioenai
Ishhod
Hashubah
Joshbekashah
Ebed-melech
Milalai
Malcam
Maon
Ehi
Ishui
Jimnah
Bechorath
Jaareshiah
Raamiah
Dalphon
Ethni
Elzaphan
Muppim
Hiel
Elpaal
Ishiah
Adlai
Dibri
Ophir
Igdaliah
Josiphiah
Jarha
Appaim
Ahimoth
Ishuah
Adbeel
Adalia
Hajehudijah
Shuthelah
Harumaph
Jehizkiah
Ahinadab
Hoham
Amasiah
Amminadib
Ahasbai
Jehallelel
Jokim
Deuel
Hammelech
Eubulus
Helon
Ahiezer
Semachiah
Igal
Gideon
Machbanai
Ithmah
Pul
Rinnah
Shillem
Jeriel
Naharai
Zedekiah
Kelal
Meshillemoth
Jeiel
Alvah
Aiah
Jidlaph
Jehudi
Ithran
Jaanai
Amon
Isui
Haddad
Imla
Ocran
Ribai
Simon Iscariot
Habazziniah
Hashabnah
Elimelech
Amos
Becher
Shemeber
Hathach
Eran
Ahi
Gaddiel
Zephon
Naphtuhim
Anani
Jehiah
Jareb
Aggaba
Gilalai
Narcissus
Obal
Shammah
Jeshohaiah
Jeuel
Dishan
Mehuman
Hashub
Azaniah
Jehush
Harhaiah
Jahleel
Shemida
Evi
Maasiai
Elidad
Phallu
Rephael
Libni
Abdi
Hasadiah
Ziphion
Rabmag
Magpiash
Shimeah
Ephlal
Malchiah
Hagab
Nepheg
Harhas
Joezer
Izhar
Mehujael
Matthan
Uriah ben Shemaiah
Izrahiah
Stachys
Isshiah
Jishui
Hachmoni
Vophsi
Jacan
Ahishar
Parnach
Jeremai
Keren-happuch
Shelomi
Kelita
Diklah
Athlai
Harnepher
Maai
Matthat
Hoshama
Mishmannah
Zeri
Sachar
Jamlech
Joed
Jaziz
Birsha
Jarah
Joel
Malchiel
Moza
Allon
Q
Rekem
Jecamiah
Gemalli
Jahzeel
Zabad
Jekamiah
Abinadab
Pethahiah
Sharar
Sheconiah
Immer
Irijah
Mahazioth
Ben Hesed
Linus
Amzi
Jaresiah
Likhi
Ishpan
Ishpah
Harum
Heldai
Hazo
Tola
Meshelemiah
Mehir
Kemuel
Ilai
Zuar
Putiel
Salu
Helek
Carmi
Jozachar
Meshullam
Machnadebai
Paseah
Piram
Caleb, son of Hezron
Zichri
Michael
Jezer
Vaniah
Nebat
Chenaanah
Hallohesh
Arodi
Eri
Ezrah
Ahishahar
Shedeur
Ahasai
Adna
Abdeel
Joshah
Arnan
Chelal
Elzabad
Rosh
Mahali
Joshibiah
Pelatiah
Romamti-ezer
Jaasau
Jaasai
Ibnijah
Elead
Elionenai
Shaphat
Hezekiah
Meremoth
Shaashgaz
Job
Habaiah
Hakkoz
Melech
Hubbah
Mibsam
Ahab
Machbena
Dodo
Uri
Enoch
Mash
Segub
Sered
Jeshishai
Bukki
Mijamin
Seled
Lahmi
Delaiah
Hori
Ziza
Jesui
Elon
Gazez
Ishvi
Aphiah
Aduel
Guni
Aristobulus
Izri
Eleasah
Izziah
Ashbel
Ahzai
Hazaiah
Mithredath
Ben Hur
Iram
Hattil
Jahmai
Carshena
Levi
Irad
Lo-Ammi
Ittai
Enan #2
Enan #1
Phalti
Adnah
Alexander
Raphu
Homam
Abitub
Azaliah
Jozabad
Harim
Rohgah
Jeush
Jerijah
Mishael
Hagabah
Mattatha
Shechem
Jathniel
Kolaiah
Ahisamach
Malluch
Jobab
Amasa
Melea
Pelaiah
Joiarib
Zebadiah
Ben Deker
Joshua the Bethshemite
Gera
Seba
Ozem
Urijah
Hasupha
Shemaiah
Ikkesh
Darda
Ahiram
Zaccur
Jaasu
Ithai
Zabdi
Maadai
Rephaiah
Arah
Ahuzzam
Nephish
Chalcol
Jephunneh
Admin
Maaziah
Genubath
Shuni
Elnaam
Shinab
Henadad
Shaaph
Melzar
Ishvah
Beno
Haahashtari
Shimi
Hadlai
Jediael
Ibsam
Naggai
Miniamin
Minjamin
Alvan
Shobal
Shammua
Shobab
Jasiel
Ephron
Elishaphat
Sodi
Jogli
Imna
Miamin
Eliathah
Jehoaddah
Nekoda
Nereus
Pelaliah
Shearjashub
Matri
Geber
Hermogenes
Mallothi
Hadadezer
Jehoshaphat
Rehum
Idbash
Zeror
Nemuel
Bigtha
Abida
Moab
Shelumiel
Obadiah
Sabtah
Antothijah
Ozni
Joshaviah
Elihoreph
Machi
Zephaniah
Heber
Hotham
Shimron
Jalon
Ner
Shemer
Kallai
Jaaziel
Meres
Mahath
Gatam
Elizur
Ishod
Jeshaiah
Jekameam
Eliphal
Peresh
Nedabiah
Aedias
Vaizatha
Parmashta
Ginath
Ishmerai
Gaddi
Peleth
Malchi-shua
Regem
Aharhel
Zabud
Hamul
Jesimiel
Ajah
Ishbah
Laadah
Gideoni
Ammizabad
Assir
Ahilud
Matthanias
Gemariah
Hareph
Pethuel
Areli
Meraioth
Chuza
Neariah
Haran
Hezron
Imri
Meraiah
Haggi
Nahath
Zuriel
Admatha
Jehozabad
Hakkatan
Elmadam
Raddai
Beriah
Huzzab
Naboth
Molid
Tahan
Joash
Japhia
On
Elienai
Elpalet
Hammoleketh
Iru
Ithream
Iri
Jehdeiah
Asiel
Shimshai
Rezon
Hanniel
Hashabiah
Maadiah
Akan
Rakem
Hanoch
Huppim
Hananiah
Baanah
Azgad
Jehubbah
Eliada
Pedahzur
Johanan son of Kareah
Chimham
Ben Abinadab
Helkai
Hasrah
Phaltiel
Pedahel
Zaavan
Melchi
Amaziah
Naum
Anan
Anak
Michri
Nahum
Ir
Jahzerah
Asriel
Elizaphan
Elpelet
Hammedatha
Nahbi
Joelah
Dodavahu
Jeezer
Josibiah
Shaharaim
Elishama
Saph
Tryphosa
Azzan
Nobah
Barachel
Laish
Jushab-hesed
Jonathan son of Kareah
Hushim
Zithri
Shephatiah
Aziel
Naphish
Marsena
Elasah
Jezrahiah
Poratha
Tyrannus
Shisha
Imrah
Ishuai
Paruah
Phurah
Eluzai
Mibhar
Ard
Jekuthiel
Pinon
Phuvah
Chelub
Ahitub
Zippor
Harbona
Jibsam
Jerah
Palti
Abijah
Hothir
Ahian
Hemam
Ben-Ammi
Hiram
Eliadah
Geuel
Gamaliel
Nehum
Merib-baal
Zohar
Jahzeiah
Sabtechah
Shiphtan
Jakeh
Naaman
Azariah
Ahlai
Athaiah
Ezbon
Nogah
Sachia
Eliasaph
Parshandatha
Paltiel
Jeatherai
Reba
Eldaah
Jaasiel
Agee
Letushim
Anaiah
Jezoar
Mnason
Lael
Ismaiah
Barkos
Regem-melech
Abimael
Zidkijah
Ephod
Karshena
Jeziah
Mushi
Ramiah
Zurishaddai
Zerah
Jamin
Obil
Ben Geber
Chenaniah
Sethur
Ishbi-benob
Jesher
Rehabiah
Maaseiah
Akkub
Eshek
Hamor
Jekoliah
Abdon
Shemuel
Adina
Nebuzaradan
Shelemiah
Jehiel
Abiel
Zobebah
Isshijah
Pildash
Uel
Jehoiada
Pagiel
Maher-shalal-hash-baz
Zalmon
Ishijah
Bela
Joahaz
Ahuzzath
Susi
Joseph
Joshua the governor of the city
Peulthai
Hod
Ispah
Hon
Mezahab
Chelluh
Shabbethai
Asareel
Barzillai
Judas of Straight Street in Damascus
Jahaziah
Abiasaph
Massa
Elnathan
Sheshan
Hodaviah
Janai
Hillel
Jakim
Jeriah
Eliphelet
Gishpa
Jemuel
Sarsekim
Hepher
Hathath
Ebed
Shagee
Jonathan son of Abiathar
Michaiah
Chislon
Jachin
Ziphah
Mikloth
Hanameel
Ishmaiah
Hobab
Jahath
Methushael
Leummim
Gamul
Mahol
Jarib
Jaaziah
This diff is collapsed.
This diff is collapsed.
Abishag
Mahalath
Jaziz
Ahab
Salome #2
Irad
Pelaiah
Damaris. Acts[41]
Hannah
Chalcol
Elienai
Nobah
Hushim
Sabtechah
Agee
Ismaiah
Adina
Isshijah
Zalmon
Abiasaph
Shagee
Chislon
/************ data model **************/
.symbol_type PersonType
.symbol_type DescriptionType
.decl person(name:PersonType, description:DescriptionType)
.input person(filename="DATA/person.facts")
.decl female(name:PersonType)
.input female(filename="DATA/female.facts")
.decl male(name:PersonType)
.input male(filename="DATA/male.facts")
.decl parent_child(p1:PersonType, p2:PersonType)
.input parent_child(filename="DATA/parent_child.facts")
.decl person_living(p:PersonType)
.input person_living(filename="DATA/person_living.facts")
/************* problem 0 **************/
/**** Find all children of Priscilla ****/
.decl p0(x:PersonType, d:DescriptionType)
// NOTE: if you want to redirect the output to a file
// you can use the syntax:
// .output p0(filename="hw2-q3-0.ans")
.output p0(IO=stdout)
p0(x,d) :- parent_child("Priscilla",x), person(x,d).
put your .sql and .txt files in this directory, one file per question.
This diff is collapsed.
*.iml
.classpath
.project
bin/
out/
.idea/
log
*.dat
dblp_simpledb.schema
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="simpledb" default="dist" basedir=".">
<property name="src" location="src"/>
<property name="testd" location="test"/>
<property name="build" location="bin"/>
<property name="build.src" location="${build}/src"/>
<property name="build.test" location="${build}/test"/>
<property name="depcache" location="${build}/depcache"/>
<property name="lib" location="lib"/>
<property name="doc" location="javadoc"/>
<property name="dist" location="dist"/>
<property name="jarfile" location="${dist}/${ant.project.name}.jar"/>
<property name="compile.debug" value="true"/>
<property name="test.reports" location="testreport"/>
<property name="sourceversion" value="1.7"/>
<path id="classpath.base">
<pathelement location="${build.src}"/>
<pathelement location="${lib}/zql.jar"/>
<pathelement location="${lib}/jline-0.9.94.jar"/>
<pathelement location="${lib}/mina-core-2.0.4.jar"/>
<pathelement location="${lib}/mina-filter-compression-2.0.4.jar"/>
<pathelement location="${lib}/slf4j-api-1.6.1.jar"/>
<pathelement location="${lib}/slf4j-log4j12-1.6.1.jar"/>
<pathelement location="${lib}/log4j-1.2.17.jar"/>
<pathelement location="${lib}/jzlib-1.0.7.jar"/>
</path>
<path id="classpath.test">
<path refid="classpath.base"/>
<pathelement location="${build.test}"/>
<pathelement location="${lib}/junit-4.5.jar"/>
<pathelement location="${lib}/javassist-3.16.1-GA.jar"/>
</path>
<!-- Common macro for compiling Java source -->
<macrodef name="Compile">
<attribute name="srcdir"/>
<attribute name="destdir"/>
<element name="compileoptions" implicit="true" optional="true"/>
<sequential>
<mkdir dir="@{destdir}"/>
<!-- avoids needing ant clean when changing interfaces -->
<depend srcdir="${srcdir}" destdir="${destdir}" cache="${depcache}"/>
<javac srcdir="@{srcdir}" destdir="@{destdir}" includeAntRuntime="no"
debug="${compile.debug}" source="${sourceversion}">
<compilerarg value="-Xlint:unchecked" />
<!--<compilerarg value="-Xlint:deprecation" />-->
<compileoptions/>
</javac>
</sequential>
</macrodef>
<!-- Common macro for running junit tests in both the test and runtest targets -->
<macrodef name="RunJunit">
<attribute name="haltonfailure" default="yes" />
<element name="testspecification" implicit="yes" />
<sequential>
<!-- timeout at 10.5 minutes, since TransactionTest is limited to 10 minutes. -->
<junit printsummary="on" fork="yes" timeout="630000" haltonfailure="@{haltonfailure}" maxmemory="128M" failureproperty="junit.failed">
<classpath refid="classpath.test" />
<formatter type="plain" usefile="false"/>
<assertions><enable/></assertions>
<testspecification/>
</junit>
</sequential>
</macrodef>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="eclipse" description="Make current directory an eclipse project">
<echo file=".project" append="false">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;projectDescription&gt;
&lt;name&gt;simpledb&lt;/name&gt;
&lt;comment&gt;&lt;/comment&gt;
&lt;projects&gt;
&lt;/projects&gt;
&lt;buildSpec&gt;
&lt;buildCommand&gt;
&lt;name&gt;org.eclipse.jdt.core.javabuilder&lt;/name&gt;
&lt;arguments&gt;
&lt;/arguments&gt;
&lt;/buildCommand&gt;
&lt;/buildSpec&gt;
&lt;natures&gt;
&lt;nature&gt;org.eclipse.jdt.core.javanature&lt;/nature&gt;
&lt;/natures&gt;
&lt;/projectDescription&gt;</echo>
<echo file=".classpath" append="false">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;classpath&gt;
&lt;classpathentry kind=&quot;src&quot; output=&quot;bin/src&quot; path=&quot;src/java&quot;/&gt;
&lt;classpathentry kind=&quot;src&quot; output=&quot;bin/test&quot; path=&quot;test&quot;/&gt;
&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot;/&gt;
&lt;classpathentry kind=&quot;output&quot; path=&quot;bin/src&quot;/&gt;
</echo>
<if> <available file="${lib}/junit-4.5.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/junit-4.5.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/jline-0.9.94.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/jline-0.9.94.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/zql.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/zql.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/mina-core-2.0.4.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/mina-core-2.0.4.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/mina-filter-compression-2.0.4.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/mina-filter-compression-2.0.4.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/jzlib-1.0.7.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/jzlib-1.0.7.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/slf4j-api-1.6.1.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/slf4j-api-1.6.1.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/slf4j-log4j12-1.6.1.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/slf4j-log4j12-1.6.1.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/log4j-1.2.17.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/log4j-1.2.17.jar&quot;/&gt;
</echo>
</then>
</if>
<if> <available file="${lib}/javassist-3.16.1-GA.jar" /> <then>
<echo file=".classpath" append="true">
&lt;classpathentry kind=&quot;lib&quot; path=&quot;lib/javassist-3.16.1-GA.jar&quot;/&gt;
</echo>
</then>
</if>
<echo file=".classpath" append="true">
&lt;/classpath&gt;
</echo>
</target>
<target name="compile" description="Compile code">
<Compile srcdir="${src}/java" destdir="${build.src}">
<classpath refid="classpath.base"/>
</Compile>
<copy todir="${build}" flatten="true">
<fileset dir="${src}">
<include name="bin/*.sh"/>
</fileset>
</copy>
</target>
<target name="javadocs" description="Build javadoc documentation">
<javadoc destdir="${doc}" access="private" failonerror="true" source="${sourceversion}">
<classpath refid="classpath.base" />
<fileset dir="src/java" defaultexcludes="yes">
<include name="simpledb/**/*.java"/>
</fileset>
</javadoc>
</target>
<target name="dist" depends="compile" description="Build jar">
<mkdir dir="${dist}"/>
<jar jarfile="${jarfile}" basedir="${build.src}">
<manifest>
<attribute name="Main-Class" value="simpledb.SimpleDb"/>
<attribute name="Class-Path" value="../lib/zql.jar ../lib/jline-0.9.94.jar ../lib/jzlib-1.0.7.jar ../lib/mina-core-2.0.4.jar ../lib/mina-filter-compression-2.0.4.jar ../lib/slf4j-api-1.6.1.jar ../lib/slf4j-log4j12-1.6.1.jar ../lib/log4j-1.2.17.jar "/>
</manifest>
<!-- Merge library jars into final jar file -->
<!--<zipgroupfileset refid="lib.jars"/>-->
</jar>
</target>
<target name="clean" description="Remove build and dist directories">
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="${doc}"/>
<delete dir="${test.reports}"/>
</target>
<target name="testcompile" depends="compile" description="Compile all unit and system tests">
<Compile srcdir="${testd}" destdir="${build.test}">
<classpath refid="classpath.test"/>
</Compile>
</target>
<target name="test" depends="testcompile" description="Run all unit tests">
<RunJunit>
<batchtest>
<fileset dir="${build.test}">
<include name="**/*Test.class"/>
<exclude name="**/*$*.class"/>
<exclude name="simpledb/systemtest/*.class"/>
</fileset>
</batchtest>
</RunJunit>
</target>
<target name="systemtest" depends="testcompile" description="Run all system tests">
<RunJunit>
<batchtest>
<fileset dir="${build.test}">
<include name="simpledb/systemtest/*Test.class"/>
</fileset>
</batchtest>
</RunJunit>
</target>
<target name="runtest" depends="testcompile"
description="Runs the test you specify on the command line with -Dtest=">
<!-- Check for -Dtest command line argument -->
<fail unless="test" message="You must run this target with -Dtest=TestName"/>
<!-- Check if the class exists -->
<available property="test.exists" classname="simpledb.${test}">
<classpath refid="classpath.test" />
</available>
<fail unless="test.exists" message="Test ${test} could not be found"/>
<RunJunit>
<test name="simpledb.${test}"/>
</RunJunit>
</target>
<target name="runsystest" depends="testcompile"
description="Runs the system test you specify on the command line with -Dtest=">
<!-- Check for -Dtest command line argument -->
<fail unless="test" message="You must run this target with -Dtest=TestName"/>
<!-- Check if the class exists -->
<available property="test.exists" classname="simpledb.systemtest.${test}">
<classpath refid="classpath.test" />
</available>
<fail unless="test.exists" message="Test ${test} could not be found"/>
<RunJunit>
<test name="simpledb.systemtest.${test}"/>
</RunJunit>
</target>
<!-- The following target is used for automated grading. -->
<target name="test-report" depends="testcompile"
description="Generates HTML test reports in ${test.reports}">
<mkdir dir="${test.reports}"/>
<!-- do not halt on failure so we always produce HTML reports. -->
<RunJunit haltonfailure="no">
<formatter type="xml"/>
<formatter type="plain" usefile="true"/>
<batchtest todir="${test.reports}" >
<fileset dir="${build.test}">
<include name="**/*Test.class"/>
<exclude name="**/*$*.class"/>
</fileset>
</batchtest>
</RunJunit>
<junitreport todir="${test.reports}">
<fileset dir="${test.reports}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.reports}" />
</junitreport>
<!-- Fail here if the junit tests failed. -->
<fail if="junit.failed" message="Some JUnit tests failed"/>
</target>
<target name="handin" depends="clean"
description="Create a tarball of your code to hand in">
<tar destfile="lab-handin.tar.bz2" compression="bzip2"
basedir="." />
<echo message="Tarball created! Please submit 'lab-handin.tar.bz2' per the instructions in the lab document." />
<subant target="dist">
<fileset dir="." includes="build.xml"/>
</subant>
</target>
<target name="test-and-handin" depends="test,systemtest,handin"
description="Run all the tests and system tests; if they succeed, create a tarball of the source code to submit" />
</project>
This diff is collapsed.
JZlib 0.0.* were released under the GNU LGPL license. Later, we have switched
over to a BSD-style license.
------------------------------------------------------------------------------
Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment