| Theorie Van Databanken 1998-1999 | Lecture 1 | http://werner.yellowcouch.org/Lectures/basicsql |
| 2. SQL Puzzles >> |
Werner Van Belle1 - werner@yellowcouch.org, werner.van.belle@gmail.com
1- Programming Technology Lab (PROG)
Department of Computer Science (DINF)
Vrije Universiteit Brussel (VUB); Pleinlaan 2; 1050 Brussel; Belgium
Abstract : In this exercise we use the output of a profiler which lists which code chunk calls another code chunk. Based on this we created a number of queries from easy to slightly more complex queries. This exercise was given in 1998-1999
De databank bestaat uit 2 tabellen. De eerste bevat al de thunks die voorkomen in de pico source code. De tweede bevat al de mogelijke calls die een thunk doet naar andere thunks.
Functies: functie*, module, lijn Calls: Caller*, Callee*
SELECT *
FROM FUNCTIES
[ORDER BY Lijn];
b. list alle regelnummers en files waar een functieheader staat
SELECT module, lijn from functies;c. list all modules, zonder duplicaten
SELECT DISTINCT MODULE FROM FUNCTIES;d. list all functions in echopri.c
SELECT functie FROM functies WHERE module = "echopri.c";e. list the module and the linenumber of all functions called from _eval_nat_
SELECT MODULE, LIJN, FUNCTIE, CALLER FROM functies, calls WHERE (functies.functie=calls.callee and calls.caller="_eval_NAT_");
SELECT COUNT(*) FROM functies;b. how many functions are there in echopri.c
SELECT COUNT(*) FROM functies WHERE module="echopri.c";c. wat is de maximumlengte van een file in dit project ?
SELECT MAX(LIJN) AS maxlijn FROM functies;
SELECT count(MODULE) FROM functies AS a WHERE NOT EXISTS (SELECT DISTINCT module from functies b where a.module=b.module and b.lijn>a.lijn);b. list het maximum aantal regelnummers per module
SELECT MODULE, LIJN FROM functies AS a WHERE NOT EXISTS (SELECT DISTINCT module from functies b where a.module=b.module and b.lijn>a.lijn);c. hoeveel verschillende modules zijn er met meer dan 1000 regelnummers ?
SELECT count(MODULE) FROM functies AS a WHERE a.lijn>1000 and NOT EXISTS (SELECT DISTINCT module from functies b where a.module=b.module and b.lijn>a.lijn);d. geef alle functies die geen enkele andere functie oproepen
SELECT functie FROM functies WHERE NOT functie IN (SELECT DISTINCT caller from calls);e. geef alle functies die enkel vanop 1 plaats opgeroepen worden
SELECT caller, callee FROM calls AS a WHERE (select count(caller) from calls b where b.callee = a.callee) = 1;f. welke thunks worden slechts vanop 1 plaats aangeroepen en roepen zelf niets anders aan ?
SELECT callee FROM calls AS a WHERE (select count(caller) from calls b where b.callee=a.callee) = 1 and not exists (select caller from calls c where c.caller=a.callee);
SELECT module, max(lijn) AS maxlijn FROM functies GROUP BY module;b. list het aantal functies per module
SELECT module, count(functie) AS aantal FROM functies GROUP BY module;c. list enkel de modules die minder dan 200 functies hebben
SELECT module, COUNT(functie) AS aantal FROM functies GROUP BY module HAVING COUNT(functie)<200;
SELECT a.module, b.caller, b.callee, c.module FROM (functies AS a INNER JOIN calls AS b ON a.functie = b.caller) INNER JOIN functies AS c ON b.callee = c.functie;b. geef een lijst die het aantal calls tussen verschillende/gelijke modules
SELECT a.module, c.module, COUNT(b.caller) AS aantal FROM (functies AS a INNER JOIN calls AS b ON a.functie = b.caller) INNER JOIN functies AS c ON b.callee = c.functie GROUP BY a.module, c.module;c. geef een lijst van het aantal calls tussen verschillende modules
SELECT a.module, c.module, COUNT(b.caller) AS aantal
FROM (functies AS a INNER JOIN calls AS b
ON a.functie = b.caller)
INNER JOIN functies AS c
ON b.callee = c.functie
GROUP BY a.module, c.module
HAVING a.module <> c.module;
| I'm currently looking for interesting work in the Basel area. If you have a challenging task with regard to data analysis and/or bioinformatics, please drop me a line. Momentan suche ich Arbeit in der Basler Umgebung. Nehmen Sie bitte kontakt auf falls Sie ein interessantes Problem im zusammenhang mit Bioinformatik und/oder Datenanalyse haben. | ![]() |