-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASSIGNMENT-4.txt
164 lines (149 loc) · 3.76 KB
/
ASSIGNMENT-4.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
ASSIGNMENT 4
(DATABASE WORKLOAD)
ADB B3 Bauyrzhan Marat
1. Query
select animals.animal_name, animals.age as animal_age, animals.domesticated, villagers.first_name as villager_name,
villagers.animal_id, villagers.age as villager_age from animals
full outer join villagers on animals.animal_id = villagers.villager_id
full outer join families on villagers.family_id = families.family_id
full outer join housings on families.house_id = housings.house_id
where competence_bonus > 0.5
or villagers.school_id in (select villagers.competence from villagers join schools on villagers.school_id = schools.school_id);
1st run2nd run3rd run4th run5th run3,0583,013,0082,9882,973
MINMAXAVG2,9733,0583,00742. Query
select count(*) from (
select villagers.first_name, villagers.last_name, villagers.age as villagers_age, villagers.school_id,
families.family_happiness, villagers.gender,
housings.condition, cast ((housings.size_in_m2 / 100) as INT) as string_size from villagers
full outer join families on villagers.family_id = families.family_id
full outer join housings on families.house_id = housings.house_id
where housings.village_id in (select villages.village_id from villages join housings on housings.village_id = villages.village_id)
or housings.condition > 0.8);
1st run2nd run3rd run4th run5th run10,54610,60610,86910,5510,823
MINMAXAVG10,54610,86910,673. Query
select count(*) from (
select * from villagers
full outer join animals on animals.animal_id = villagers.animal_id
full outer join families on villagers.family_id = families.family_id
full outer join housings on housings.house_id = families.house_id
full outer join villages on villages.village_id = housings.village_id
full outer join locations on locations.location_id = villages.location_id
where animals.animal_id in
(select animals.animal_id from animals where animals.animal_id in
(select animal_id from animals where animal_name like 'Gol%' and (substr(animal_name, 7,2) like 'ey')))
or villagers.school_id is not null
or villages.popularity > 0.5
or locations.condition >= (select avg(condition) from locations));
1st run2nd run3rd run4th run5th run1,6741,5791,61,1551,182
MINMAXAVG1,1551,6741,4384. Transaction
update jobs
set wage = 17
where risk_factor > (select avg(risk_factor) from jobs)
or round(required_competence) >= (select round(avg(required_competence)) from jobs)
or substr(job_name, 2,3) like '%ata%' and end > '04/20/1948'
or job_id in (select job_id from locations
where number_of_trees > (select avg(number_of_trees) from locations));
1st run2nd run3rd run4th run5th run7,4289,4778,5099,4197,527
MINMAXAVG7,4289,4778,4725. Transaction
delete from VILLAGERS
where first_name = 'Burnard' and gender = 'female'
or substr(last_name, 2,3) not like '%a' and hapiness < (select avg(hapiness) from villagers);
1st run2nd run3rd run4th run5th run4,2514,5234,6094,6774,571
MINMAXAVG4,2514,6774,5266. Transaction
update villages
set popularity = (select avg(popularity) from villages
where villages.village_id in (select villages.village_id from housings join villages on housings.village_id = villages.village_id)
and substr(village_name, 2,3) like '%aji%' and hospital <> 'false'
or location_id in (select location_id from locations
where number_of_trees > (select avg(number_of_trees) from locations)));
1st run2nd run3rd run4th run5th run3,2443,6053,4473,5233,369
MINMAXAVG3,2443,6053,437