SQL Final FPT

0.0(0)
Studied by 1 person
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/75

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:20 PM on 8/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

76 Terms

1
New cards

Database Concepts & ER Models

A. Structured Query Language

2
New cards

Which of the following is described graphically using an E-R diagram?

C. Entities and relationships between entities

3
New cards

SQL query and modification commands make up a(n)

B. DML

4
New cards

A/an____ property of the entity and it quantifies, qualifies, classifies or specifies the entity. is a piece of information that in some way describes an entity. It is a

D. Attribute

5
New cards

What is the purpose of a Unique Constraint?

D. To identify one unique instance of an entity, by using one or more attributes and/or relationships

6
New cards

Which of the following entities most likely contains invalid attributes?

C. Entity : Car. Attributes : Owner Occupation, Owner Salary, Speed

7
New cards

In a 1 : N relationship, the foreign key is placed in :

C. the child table

8
New cards

You are building a new database for a company with 10 departments. Each department contains multiple employees. In addition, each employee might work for several departments. How should you logically model the relationship between the department entity?

B. Create a new entry, create a one-to-many relationship from the employee to the new entry, and create a one-to-many relationship from the department entry to the new entry.

9
New cards

In which of the following can many entity instances of one type be related to many entity instances of another type?

C. Many-to-Many Relationship

10
New cards

In a 1 : 1 relationship, the foreign key is placed in

A. either table without specifying parent and child tables

11
New cards

What is MS SQLServer?

D. Microsoft SQL Server is a database platform for online Transaction Processing (OLTP), data warehousing, e-commerce application. It is also a business intelligence platform for data intergration, analysis, and reporting solutions.

12
New cards

What is components of MS SQL server?

A. Database Engine, Intergration Services, Reporting Services, Analysis Services.

13
New cards

What is database engine?

C. Database Engine is the core service for storing, processing, and securing data.

14
New cards

What is integration services (SSIS)?

B. Integration Services (SISS) is a platform for building high performance data intergration solutions, including extraction, transformation, and load packages for data warehousing.

15
New cards

What data type is "Distance from home to school "should be?

A. Decimal

16
New cards

Which of the following is not an operator in categories of SQL Comparison Operators?

C. Addition (+)

17
New cards

What is the storage size of smallmoney data type?

C. 4 bytes

18
New cards

DECLARE @message CHAR(10), @error_id INT

SET @message = 'Error: '

SET @error_id = 1

IF @error_id=1

SET @message = @message+' this field is not define'

PRINT @message

When execute the code, which message is printed:

A. Error:

19
New cards

To sum integers from 1 to 10 by using a WHILE loop. Consider the following code snippet:

DECLARE @i INT, @sum INT

SET @i=1

SET @sum=0

WHILE @i

D. The loop never stops

20
New cards

The NULL SQL keyword is used to ...

D. represent a missing or unknown value.

21
New cards

What is the purpose of the SQL AS clause?

C. The AS SQL clause is used change the name of a column in the result set or to assign a name to a derived column.

22
New cards

Which of the following SQL statements is used to delete both the structure and data of the named table STUDENT ?

A. DROP TABLE STUDENT

23
New cards

Which of the following SQL statements is used create database FASM in SQL Server?

C. CREATE DATABASE FASM;

24
New cards

Which one of the following deletes all the entries but keeps the structure of the relation.

D. Delete from instructor;

25
New cards

The SQL ALTER statement can be used to:

A. change the table structure

26
New cards

SQL data definition commands make up a(n) ________________

A. DDL

27
New cards

Identify the correct syntax for IDENTITY property?

A. Column-name Data type IDENTITY(SEED, INCREMENT)

28
New cards

A primary key constraint cannot be deleted if it is being referenced by a foreign key constraint in another table; the foreign key constraint must be deleted first?

A. TRUE

29
New cards

A foreign key is:

A. a column containing the primary key of another table

30
New cards

The difference between the DELETE and TRUNCATE SQL clauses is:

C. The TRUNCATE clause deletes all rows in a database table, while the DELETE clause can have a WHERE condition and might or might not delete all rows in a table.

31
New cards

LOCATIONS(subject_code, department_name, location_id, city);

Which code snippet will alter the table LOCATIONS and change the datatype of the column CITY to varchar(30)?

C. ALTER TABLE locations ALTER COLUMN city varchar(30)

32
New cards

Which of the following is not true about complex views?

B. They contain no functions or grouping.

33
New cards

Which of the following code will delete a view named all_marks_english?

B. drop view all_marks_english;

34
New cards

What is an index ?

B. An index is a database table attribute, which speeds-up data search within a table.

35
New cards

Which is the purpose of index in SQL server?

D. All of the above

36
New cards

Which one of the following is not true for a view?

B. They contain no functions or grouping

37
New cards

Refer below query which leads to create a view named vwEmployee?

CREATE vwEmployee VIEW

AS

SELECT nothing

FROM dbo.Employee

WHERE ID < 100

Now, tell the problem in query?

B. View name must be after keyword view and 'nothing' is not keyword, so should be replace with *.

38
New cards

Given SQL statement:

UPDATE Products

SET UnitPrice = UnitPrice + (UnitPrice * .10)

WHERE UnitPrice BETWEEN 60 AND 70

Which of the following is true ?

B. 10% price increase (UnitPrice) in the Products table, for products priced between 60 and 70.

39
New cards

In the UPDATE statement, if we do not use the WHERE clause, then:

D. All of the records will be updated

40
New cards

The SQL WHERE clause

B. limits the row data are returned.

41
New cards

The SQL keyword(s) ________ is used with wildcards.

A. LIKE only

42
New cards

Which of the following is true about the COUNT function?

D. All are true.

43
New cards

Given the following table and query:

Employee (employee_id, name, salary)

(1001, 'Annie', 6000),

(1009, 'Ross', 4500),

(1018, 'Zeith', 7000)

and

SELECT * FROM employee WHERE employee_id>1009;

D. 1018

44
New cards

The following table

BOOK_INFORMATION(book_id, book_title, price)

Which SQL statement allows you to insert the following price of data into BOOK_INFORMATION ?

C. INSERT INTO BOOK_INFORMATION VALUES (20, 'FRESHER ACADEMY SQL TUTORIAL', 15);

45
New cards

: The following table:

BOOK_INFORMATION(book_id, book_title, price)

Which SQL statement will you use to change the price for the BOOK titled 'ELEMENTARY SCHOOL GUIDE' to 20?

A. UPDATE BOOK_INFORMATION SET price = 20 WHERE book_title = 'ELEMENTARY SCHOOL GUIDE';

46
New cards

Which SQL keyword is used to remove duplicate rows in the result of an SQL query SELECT ?

D. DISTINCT

47
New cards

Consider the following schema:

products (ProductName, UnitPrice, UnitsInStock)

Which of the following query statements is syntax error?

SELECT ProductName FROM products WHERE (UnitPrice < 10) , (UnitsInStock > 5);

48
New cards

Given below data in the following table:

Example_Table (Number, Name)

(1, 'One'),

(2, 'Two'),

(3, 'Three'),

(4, 'Four'),

(5, 'Five'),

(1, 'One'),

(NULL, NULL)

and the query:

SELECT COUNT(*) FROM Example_Table as COUNT

SELECT COUNT_BIG(*) FROM Example_Table as COUNT_BIG

Result of the above two queries is:

B. 7,7

49
New cards

Which one is correct syntax for applying UNION operator:

SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2;

50
New cards

Which of the following query is correct to select the highest salary of the employees in each Department?

C. SELECT e.dept_id, MAX(e.salary) FROM Employee e GROUP BY e.dept_id;

51
New cards

SELECT i.name FROM instructor i

WHERE i.dept_name = 'Physics'

ORDER BY i.name;

By default, the order by clause lists items in ______ order.

D. Ascending

52
New cards

What is the difference between the WHERE and HAVING SQL clauses

A. The WHERE SQL clause condition(s) is applied to all rows in the result set before the HAVING clause is applied (if present). The HAVING clause is used only with SELECT SQL statements and specifies a search condition for an aggregate or a group.

53
New cards

Given the following table:

BOOK_INFORMATION(book_id, book_title, price)

Which of the following SQL statements would find all books whose title starts with 'A'?

SELECT book_id, book_title FROM BOOK_INFORMATION WHERE book_title LIKE '%A';

54
New cards

Given the following table:

SALES (store_id, sales_date, sales_amount)

Which of the following SQL statements would list all stores that total sales amount is over 5000?

SELECT store_id, SUM(sales_amount)

FROM SALES

GROUP BY store_id

HAVING SUM(sales_amount) > 5000;

55
New cards

What does the UNION operator do?

C. The UNION operator combines the results of two or more queries into one result that includes all the rows from the queries in the union.

56
New cards

Which of the following query would show the total number of lines in the 'emp' table?

C. SELECT count(*) FROM emp

57
New cards

Consider the following table:

Product(productId, name, cost)

Which of the following query would display the lowest of cost in the Product table?

B. Select min(cost) from Product;

58
New cards

Consider the following table and query:

Bill(bill_id, export_date, customer_id)

and

SELECT COUNT(bill_id)

FROM Bill

GROUP BY export_date;

Which of the following is true?

C. List out number of bills by the date

59
New cards

We are running below query on 4-Apr-2014 at 9:25 am

SELECT CONCAT('Date & Time:', GETDATE()+7-6)

It will return

D. Date & Time: Apr 5 2014 9:25AM

60
New cards

What is purpose of CAST function in SQL Server?

A. It converts or cast an expression of 1 data type to another

61
New cards

Give 2 tables have schema as bellow:

STUDENT(studentId, firstName, lastName, departmentId)

RESULT(studentId, subjectId, score).

To select students in the TH department with the highest average of score, which statement should you use?

SELECT kq.studentId, sv.firstName, sv.lastName, AVG(kq.score)

FROM dbo.Result kq INNER JOIN dbo.Student sv ON kq.studentId=sv.studentId

WHERE sv.departmentId='TH'

GROUP BY kq.studentId, sv.firstName, sv.lastName HAVING AVG(kq.score) IN

(SELECT TOP 1 AVG(kq.score)

FROM dbo.Result kq INNER JOIN dbo.Student sv ON kq.studentId=sv.studentId

WHERE sv.departmentId='TH'

GROUP BY kq.studentId ORDER BY AVG(kq.score) DESC);

62
New cards

In SQL, the ABS function used for?

A. To return the absolute, positive value of a numeric expression

63
New cards

The AVG SQL function returns the ...

C. average in the values in agroup

64
New cards

A data manipulation command the combines the records from one or more tables is called

C. JOIN

65
New cards

Give the database schema the following tables:

Student (studentId, firstName, lastName, gender, birthday, phone, address, classId)

Class (classId, className)

Which code snippet will list the id and names of class with more than 15 students?

SELECT c.classId, c.className, COUNT(*) AS amount FROM dbo.Class c INNER JOIN dbo.Student s ON c.classId = s.classId

GROUP BY c.classId, c.className HAVING COUNT(*) > 15;

66
New cards

Give the database schema the following tables:

Student (studentId, firstName, lastName, gender, birthday, phone, address, classId)

Class (classId, className)

Which code snippet will display records with the following three columns: classId, className and amount (amount of students)?Class

SELECT c.classId, c.className, COUNT(*) AS amount FROM dbo.Class c INNER JOIN dbo.Student s ON c.classId = s.classId

GROUP BY c.classId, c.className;

67
New cards

For the following tables (schema is 'asql'):

Student(studentId, studentName, address)

('S01', 'Nguyen Van An', 'Hanoi'),

('S02', 'Pham Tuan Anh', 'Hanoi'),

('S03', 'Nguyen Minh Quan', 'Danang')

Result(studentId, subjectId, score)

('S01', 'J01', 8),

('S01', 'S01', 7),

('S02', 'J01', 3)

Subject(subjectId, subjectName)

('S01', 'SQL Basics'),

('J01', 'Programming Java'),

('N01', 'Programming C#')

and a query:

SELECT s.studentName, r.subjectId, r.score FROM asql.Student s JOIN asql.Result r ON s.studentId =r.studentId;

What is the result of the query?

Nguyen Van An J01 8

Nguyen Van An S01 7

Pham Tuan Anh J01 3

68
New cards

For the following tables:

Customers (CustomerID, CustomerName, PhoneNumber, Address)

Orders (OrderID, OrderDate, CustomerID)

To return the CustomerName and OrderDate that the result must include the customers who have not placed any orders. Which Transact-SQL query should you use?

SELECT CustomerName, OrderDate

FROM Customers LEFT OUTER JOIN Orders

ON Customers.CustomerID = Orders.CustomerID;

69
New cards

Which one is NOT type of Outer Join ?

D. BOTH JOIN

70
New cards

Product (Product_No, Name)

('S101', 'A'),

('S102', 'B'),

('S103', 'C'),

'S104', 'D')

Sales_Details (Sales_No, Product_No, Quantity)

('U001', 'S101', 5),

('U002', 'S104', 2),

('U002', 'S101', 10),

('U003', 'S103', 5),

('U003', 'S104', 8)

and

SELECT X.Produduct_No FROM Product X LEFT OUTER JOIN Sales_Details Y ON X.Product_No=Y.Product_No;

A. S101, S101, S102, S103, S104, S104

71
New cards

The following SQL is which type of join :

SELECT CUSTOMER_T.CUSTOMER_ID, ORDER_T.CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T, ORDER_T ;

B. CROSS JOIN

72
New cards

We refer to a join as a self-join when?

D. we are joining table to itself

73
New cards

SELECT X.PK

FROM TableX X

LEFT JOIN TABLEY Y

ON X.PK = Y.PK

WHERE Y.PK IS NULL

What is result of the query?

4 5 10

74
New cards

SELECT Y.PK

FROM TableX X

RIGHT JOIN TABLEY Y

ON X.PK = Y.PK

WHERE X.PK IS NULL

What is result of the query?

8 9 11

75
New cards

SELECT Y.PK

FROM TableX X

FULL OUTER JOIN TABLEY Y

ON X.PK = Y.PK

WHERE X.PK IS NULL OR Y.PK IS NULL

What is result of the query?

NULL NULL 8 9 NULL 11

76
New cards

How many tables can be included with a join ?

D. All of the mentioned options