-
Notifications
You must be signed in to change notification settings - Fork 0
/
DriverW7.java
71 lines (66 loc) · 2.12 KB
/
DriverW7.java
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
69
70
71
import java.util.*;
public class DriverW7 {
public static void main(String args[]) {
Database db = new Database();
ArrayList<String> attr1 = new ArrayList<String>();
attr1.add("SID");
attr1.add("SNAME");
attr1.add("PHONE");
attr1.add("MAJOR");
attr1.add("GPA");
ArrayList<String> dom1 = new ArrayList<String>();
dom1.add("INTEGER");
dom1.add("VARCHAR");
dom1.add("INTEGER");
dom1.add("VARCHAR");
dom1.add("DECIMAL");
Relation r1 = new Relation("REL1",attr1,dom1);
Tuple t = new Tuple(attr1,dom1);
t.addIntegerComponent(1111);
t.addStringComponent("Robert Adams");
t.addIntegerComponent(1234);
t.addStringComponent("Computer Science");
t.addDoubleComponent(4.0);
r1.addTuple(t);
t = new Tuple(attr1,dom1);
t.addIntegerComponent(1112);
t.addStringComponent("Charles Bailey");
t.addIntegerComponent(5656);
t.addStringComponent("Computer Science");
t.addDoubleComponent(3.5);
r1.addTuple(t);
t = new Tuple(attr1,dom1);
t.addIntegerComponent(1113);
t.addStringComponent("David Beatle");
t.addIntegerComponent(1212);
t.addStringComponent("Mathematics");
t.addDoubleComponent(3.5);
r1.addTuple(t);
t = new Tuple(attr1,dom1);
t.addIntegerComponent(1114);
t.addStringComponent("Graham Gooch");
t.addIntegerComponent(5678);
t.addStringComponent("Computer Science");
t.addDoubleComponent(3.5);
r1.addTuple(t);
db.addRelation("STUDENT",r1);
System.out.println(r1);
ArrayList<String> cnames1 = new ArrayList<String>();
cnames1.add("SID");
cnames1.add("GPA");
Relation r2 = r1.project(cnames1);
r2.setName("PROJECT_SID_GPA_STUDENT");
System.out.println(r2);
ArrayList<String> cnames2 = new ArrayList<String>();
cnames2.add("MAJOR");
cnames2.add("GPA");
Relation r3 = r1.project(cnames2);
r3.setName("PROJECT_MAJOR_GPA_STUDENT");
System.out.println(r3);
ArrayList<String> cnames3 = new ArrayList<String>();
cnames3.add("MAJOR");
Relation r4 = r1.project(cnames3);
r4.setName("PROJECT_MAJOR_STUDENT");
System.out.println(r4);
}
}