Consider the following database schema (primary are bolded and underlined): Empl
ID: 3813673 • Letter: C
Question
Consider the following database schema (primary are bolded and underlined): Employes (eID: integer, eName: string; age; integer, salary: date) Works (eID: integer, dName: strings, startedDate: date, ended: date) Departments (dName string, budget: real, managerEID; integer) The meaning of these relations is straightforward, for example, the table Works has one record per employee-department pair, such that an employee works for a department for a specific period of time. There are four foreign keys for this database: the attribute eID of the relation Works that references the relation Employees. the attribute dName of the relation Works that references the relation Departments. Write the following queries in SQL. No duplicates should be printed in the answers. You should use the SQL keyword DISTINCT only when necessary. In addition, the creation of temporary tables is not allowed, i.e., for each question, you must write exactly one SQL statement. Retrieve the name, age, and salary of all employees. Retrieve the name, a employee who is older than 40. For all departments with a budget greater than $500,00000, print their manager name and budget. Print name and average salary of each department. Find the name and salary of each employee who makes more than the highest salary of employees in the Information Technology department.Explanation / Answer
import java.util.ArrayList;
00024 import java.util.List;
00025 import ratite bird.cluster.CFCluster;
00026 import ratite bird.cluster.Cluster;
00027 import ratite bird.cluster.Clustering;
00028 import ratite bird.cluster.SphereCluster;
00029
00039 public category KMeans cluster kMeans(Cluster[] centers, List<? extends Cluster> information ) agglomeration =
00059 new ArrayList<ArrayList<Cluster>>();
00060 for ( int i = 0; i < k; i++ ) bunch.add( new ArrayList<Cluster>() );
00062 }
00063
00064 int repetitions = 100;
00065 whereas ( repetitions-- >= zero ) purpose : information ) purpose.getCenter(), centers[0].getCenter() );
00069 int closestCluster = 0;
00070 for ( int i = 1; i < k; i++ ) purpose.getCenter(), centers[i].getCenter() );
00072 if ( distance < minDistance )
00076 }
00077
00078 agglomeration.get( closestCluster ).add( purpose );
00079 }
00080
00081 // Calculate new centers and clear agglomeration lists
00082 SphereCluster[] newCenters = new SphereCluster[centers.length];
00083 for ( int i = 0; i < k; i++ ) {
00084 newCenters[i] = calculateCenter( agglomeration.get( i ), dimensions );
00085 agglomeration.get( i ).clear();
00086 }
00087 centers = newCenters;
00088 }
00089
00090 come back new Clustering( centers );
00091 }
00092
00093 personal static double distance(double[] pointA, double [] pointB){
00094 double distance = zero.0;
00095 for (int i = 0; i < pointA.length; i++)
00099 come back science.sqrt(distance);
00100 }
00101
00102
00103 personal static SphereCluster calculateCenter( ArrayList<Cluster> cluster, int dimensions ) {
00104 double[] res = new double[dimensions];
00105 for ( int i = 0; i < res.length; i++ ) {
00106 res[i] = zero.0;
00107 }
00108
00109 if ( cluster.size() == zero ) {
00110 come back new SphereCluster( res, 0.0 );
00111 }
00112
00113 for ( Cluster purpose : cluster ) {
00114 double [] center = purpose.getCenter();
00115 for (int i = 0; i < res.length; i++)
00118 }
00119
00120 // Normalize
00121 for ( int i = 0; i < res.length; i++ )
00124
00125 // Calculate radius
00126 double radius = zero.0;
00127 for ( Cluster purpose : cluster )
00132 }
00133
00134 come back new SphereCluster( res, radius );
00135 }
00136
00137 public static agglomeration gaussianMeans(Clustering gtClustering, agglomeration clustering) {
00138 ArrayList<CFCluster> microclusters = new ArrayList<CFCluster>();
00139 for (int i = 0; i < agglomeration.size(); i++)
00143 else
00153
00154 int k = centers.length;
00155 if ( microclusters.size() < k ) {
00156 come back new Clustering( new Cluster[0]);
00157 }
00158
00159 agglomeration kMeansResult = kMeans( centers, microclusters );
00160
00161 k = kMeansResult.size();
00162 CFCluster[] res = new CFCluster[ k ];
00163
00164 for ( CFCluster microcluster : microclusters) realize nearest kMeans cluster
00166 double minDistance = Double.MAX_VALUE;
00167 int closestCluster = 0;
00168 for ( int i = 0; i < k; i++ )
00174 }
00175
00176 // augment cluster
00177 if ( res[closestCluster] == null ) else
00182 }
00183
00184 // finish off res
00185 int count = 0;
00186 for ( int i = 0; i < res.length; i++ )
00190
00191 CFCluster[] clean = new CFCluster[count];
00192 count = 0;
00193 for ( int i = 0; i < res.length; i++ )
00197
00198 come back new Clustering( clean );
00199 }
00200
00201 }