Recent questions tagged sql

1 1 vote
1 1 answer
85
85 views
Consider:$\mathrm{DEPT(dname,\ location)}$$\mathrm{STUDENT(name,\ regno,\ gpa,\ level,\ dept)}$$\mathrm{COURSE(cno,\ cname,\ dept)}$$\mathrm{TAKE(regno,\ cno)}$and the SQ...
0 0 votes
1 1 answer
51
51 views
Consider relations $\mathrm{R}$ and $\mathrm{S}$.Five SQL commands are shown:Command I :SELECT R.* FROM R WHERE EXISTS (SELECT * FROM S WHERE R.a = S.c);Command II :SELEC...
0 0 votes
1 1 answer
41
41 views
Consider:$\mathrm{Observation(Seq,\ BirdName,\ ObservationCount)}$with primary key:$\mathrm{(Seq,\ BirdName)}$The following statement inserts combinations of sequence num...
0 0 votes
1 1 answer
48
48 views
Relation $\mathrm{R1(A,B)}$ contains:$$\begin{array}{|c|c|} \hline \mathrm{A} & \mathrm{B} \\ \hline 1 & 2 \\ 2 & 2 \\ 3 & 3 \\ 4 & 3 \\ 4 & 2 \\ 4 & 1 \\ 5 & 0 \\ \hline...
0 0 votes
1 1 answer
39
39 views
Consider the relation:$$\begin{array}{|c|c|c|} \hline \mathrm{EmployeeCode} & \mathrm{Supervisor} & \mathrm{Name} \\ \hline \mathrm{S001} & \mathrm{NULL} & \mathrm{A} \\ ...
0 0 votes
1 1 answer
81
81 views
Relevant relations are:$\mathrm{BUILDING(BID,\ BName,\ Address)}$$\mathrm{IN\_BUILDING(EID,\ BID)}$Which of the following queries correctly find the names of buildings wh...
0 0 votes
1 1 answer
58
58 views
Consider relations:$\mathrm{Product}$$\mathrm{Inventory}$where the underlined attributes in the original examination are primary keys.The following query returns product ...
0 0 votes
1 1 answer
54
54 views
Consider,SELECT DISTINCT TBL1.COL1 FROM TBL1 WHERE COL1 IN (SELECT COL1 FROM TBL2);Which SQL statement produces the same result?SELECT DISTINCT TBL1.COL1 FROM TBL1 UNION ...
1 1 vote
2 2 answers
68
68 views
Consider the relation $R(a,b)$. The relation may contain duplicate tuples.Which of the following queries are guaranteed not to contain duplicate tuples, regardless of the...
0 0 votes
1 1 answer
120
120 views
Three relations with the same schema are maintained for three regions:$\mathrm{TokyoProduct}$, $\mathrm{NagoyaProduct}$, and $\mathrm{OsakaProduct}$$\mathrm{ProductNo}$ i...
0 0 votes
1 1 answer
111
111 views
The database contains relations $\mathrm{animals}$ and $\mathrm{visits}$, with $\mathrm{aid}$ identifying an animal.Which SQL query returns the names of animals that visi...
0 0 votes
1 1 answer
89
89 views
Conceptually, in which order does SQL process the following three operations?$\mathrm{WHERE}\rightarrow\mathrm{HAVING}\rightarrow\mathrm{GROUP\ BY}$ $\mathrm{WHERE}\right...
0 0 votes
1 1 answer
100
100 views
The $\mathrm{Employee}$ relation contains:$$\begin{array}{|c|c|c|c|} \hline \mathrm{EmployeeNo} & \mathrm{Name} & \mathrm{DateOfBirth} & \mathrm{Department} \\ \hline 000...
0 0 votes
1 1 answer
99
99 views
The relation is:$\mathrm{Midterm}(\mathrm{ClassName},\mathrm{SubjectName},\mathrm{StudentNo},\mathrm{Name},\mathrm{Score})$.The objective is to calculate the average scor...
0 0 votes
1 1 answer
106
106 views
The relation $\mathrm{ExamResult}$ stores examination records for the previous three years:$\mathrm{ExamResult}(\mathrm{StudentNo},\mathrm{ExamDate},\mathrm{Score},\mathr...
2 2 votes
1 1 answer
221
221 views
Relation $\mathrm{R}(\mathrm{at1},\mathrm{at2},\mathrm{at3})$ contains: $$\begin{array}{|c|c|c|} \hline \mathrm{at1} & \mathrm{at2} & \mathrm{at3} \\ \hline 12 & 15 & 510...
0 0 votes
1 1 answer
121
121 views
A concert-ticket system contains $\mathrm{Sales}$ and $\mathrm{Payment}$.Relevant rules are:a row is placed in $\mathrm{Sales}$ when a purchase application is made; if pa...
2 2 votes
1 1 answer
122
122 views
Consider the relation: $$\begin{array}{c}\mathbf{EmployeeQualification} \\[4pt]\begin{array}{|c|c|}\hline\mathrm{EmployeeCode} & \mathrm{Qualification} \\\hline\mathrm{S0...
1 1 vote
1 1 answer
121
121 views
Consider the following tables.The following SQL query is executed:SELECT AVG(TotalSales) AS AverageSales FROM Product LEFT OUTER JOIN ProductSales ON Product.ProductCode ...
1 1 vote
1 1 answer
119
119 views
Consider,$\mathrm{Users}(\mathrm{userid},\mathrm{name},\mathrm{age})$$\mathrm{Dogs}(\mathrm{dogid},\mathrm{owner},\mathrm{name},\mathrm{breed},\mathrm{age})$$\mathrm{dogi...
1 1 vote
1 1 answer
106
106 views
Let $\mathrm{R}$ and $\mathrm{S}$ be relations.For which of the following relational operations is it not necessary that $\mathrm{R}$ and $\mathrm{S}$ be union-compatible...
0 0 votes
1 1 answer
109
109 views
The database contains:$\mathrm{Users}(\mathrm{uid},\mathrm{name},\mathrm{dob},\mathrm{user\_type})$$\mathrm{Posts}(\mathrm{pid},\mathrm{folder},\mathrm{summary})$$\mathrm...
3 3 votes
1 1 answer
130
130 views
The Adjacency List table stores the data for the tree structure shown below. Which SQL keyword should be inserted at $\mathbf{[a]}$ to retrieve the leaf nodes of the tree...
1 1 vote
1 1 answer
97
97 views
Consider:SQL Statement $\mathbf{1}$$\mathrm{SELECT\ *}$ $\mathrm{FROM\ R}$ $\mathrm{UNION}$ $\mathrm{SELECT\ *}$ $\mathrm{FROM\ R}$;SQL Statement $\mathbf{2}$$\mathrm{SEL...
1 1 vote
1 1 answer
103
103 views
Consider the following $\mathrm{Product}$ table:$$\begin{array}{|c|c|c|c|} \hline \mathrm{ProductID} & \mathrm{Product} & \mathrm{SupplierID} & \mathrm{UnitPrice} \\ \hli...
3 3 votes
1 1 answer
210
210 views
Given:$\mathrm{Homes}(\mathrm{home\_id},\mathrm{city},\mathrm{bedrooms},\mathrm{bathrooms},\mathrm{area})$$\mathrm{Transactions}(\mathrm{home\_id},\mathrm{buyer\_id},\mat...
0 0 votes
1 1 answer
136
136 views
Given the relation: $$\begin{array}{|c|c|c|c|} \hline \mathrm{Sname} & \mathrm{Sid} & \mathrm{Region} & \mathrm{Quota} \\ \hline \mathrm{Frances} & 25 & \mathrm{TX} & 100...
0 0 votes
1 1 answer
141
141 views
An auditing company was hired to analyze the database of the SUS (Unified Health System). Its first task is to identify pairs of registered doctors who have the same name...
0 0 votes
1 1 answer
112
112 views
Two tables are given below : $$\begin{array}{c@{\qquad}c}\mathrm{\mathbf{Orders}} & \mathrm{\mathbf{Products}} \\[4pt]\begin{array}{|c|c|c|}\hline\mathrm{Date} & \mathrm{...
0 0 votes
1 1 answer
126
126 views
A table $\mathrm{Scores}$ stores each student's marks in Japanese and Mathematics.Let,$A$ mean the student's Japanese score is at least the Japanese average.$B$ mean the ...