Chủ Nhật, 23 tháng 10, 2016

[BSQL] SQL Basics Quiz


Nếu không tìm thấy câu hỏi, hãy thử tìm bằng câu trả lời.
Which of the following is a legal expression in SQL?
Answer: SELECT NAME FROM EMPLOYEE;

The statement in SQL which allows change the definition of a table is:
Answer: Alter.

Which is the SQL constraint that allows inputting NULL in a specified column in a DBMS table but that does not allow inputting the already entered value?
Answer: UNIQUE

Which of the following product groups can be found when searching the “Product Inventory” table for products with a sales price of 500 dollars or more per unit and an inventory of less than 10 units?
Answer: Medium refrigerator, small refrigerator, and air conditioner

SQL stands for _____
Answer: Structured Query Language

Given below data in the Leased_Apartment_Table table If the following statement is executed, which data group is extracted? SELECT Property FROM Leased_Apartment_Table WHERE (District=’Tu Liem’ OR Time_From_The_Station<15) AND (Floor_Space>60)
Answer: A, C

Which of the following is not the SQL statement?
Answer: DIVIDE

You want to create a table to store Microsoft Word documents. You need to ensure that the documents must only be accessible via Transact-SQL queries. Which Transact-SQL statement should you use?
Answer: CREATE TABLE DocumentStore ( [Id] INT NOT NULL PRIMARY KEY, [Document] VARBINARY(MAX) NULL ) GO

Which of the following SQL statements defines a schema?
Answer: CREATE

There is a student score table shown below with basic and advanced subject codes which begin with letters B and A respectively. Which of the following SQL statements can be used to retrieve students, from the score table, whose basic subject score is 70 or more and examination date is 2007-05-04?
Answer: SELECT student_number FROM score_table WHERE score >=70 AND examination_date = ‘2007-05-04’ AND subject_code LIKE ‘B%’

Which of the following SQL statements can extract employee name’s whose salary is $10000 or higher from the table “human_resource”?
Answer: SELECT employee_name FROM human_resource WHERE salary>=10000

Which of the following is the appropriate SQL statement that is used to create Table A from Persons Table?
Answer: SELECT name FROM Persons WHERE country LIKE '%Korea%' AND gender = 'F' OR age = 26

SQL data definition commands make up a(n) _______
Answer: DDL

Which of the following operations extracts specific columns from tables in a relational database?
Answer: Projection

Which of the following SQL statements corresponds to the “projection” operation of the relational algebra that can extract only the column “Continent” from the table “Country” and eliminate duplicates from the records returned?
Answer: SELECT DISTINCT Continent FROM Country

You develop a database for a travel application. You need to design tables and other database objects. You create a view that displays the dates and times of the airline schedules on a report. You need to display dates and times in several international formats. What should you do?
Answer: Use the DATETIME2 data type.

Which of the following SQL statements for the stated table “Shipment_Record” produces the largest value as a result of its execution?
Answer: SELECT COUNT(*) FROM shipment_record

‘AS’ clause is used in SQL for:
Answer: Rename operation.

Your database contains a table named Purchases. The table includes a DATETIME column named PurchaseTime that stores the date and time each purchase is made. There is a non-clustered index on the PurchaseTime column. The business team wants a report that displays the total number of purchases made on the current day. You need to write a query that will return the correct results in the most efficient manner. Which Transact-SQL query should you use?
Answer: SELECT COUNT(*) FROM Purchases WHERE PurchaseTime >= CONVERT(DATE, GETDATE()) AND PurchaseTime < DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))

You are a database developer of a Microsoft SQL Server database. The database contains a table named Customers that has the following definition: You need to ensure that the CustomerId column in the Orders table contains only values that exist in the CustomerId column of the Customer table. Which Transact-SQL statement should you use?
Answer: ALTER TABLE Orders ADD CONSTRAINT FX_Orders_CustomerID FOREIGN KEY (CustomerId) REFERENCES Customer (CustomerId)

Which of the following two descriptions on the operation of the stated customer_table is wrong? Operation 1: SELECT CUSTOMER_NAME, ADDRESS FROM CUSTOMER Operation 2: SELECT * FROM CUSTOMER WHERE CUSTOMER_NO = ‘D0010’
Answer: The table extracted by operation 2 has two columns

A primary key is combined with a foreign key creates:
Answer: Parent-Child relationship between the tables that connect them

You develop a Microsoft SQL Server 2012 database. The database is used by two web applications that access a table named Products. You want to create an object that will prevent the applications from accessing the table directly while still providing access to the required data. You need to ensure that the following requirements are met: Future modifications to the table definition will not affect the applications' ability to access data. The new object can accommodate data retrieval and data modification. You need to achieve this goal by using the minimum amount of changes to the existing applications. What should you create for each application?
Answer: Views

The database schema is written in:
Answer: DDL

Which of the following is a comparison operator in SQL?
Answer: All of the above

SQL is:
Answer: a data sublanguage.

The ______ operator is used to compare a value to a list of literals values that have been specified.
Answer: IN

Which of the following aggregate functions does not ignore nulls in its results?.
Answer: COUNT (*)

[BSQL] DB Design Quiz


Nếu không tìm thấy câu hỏi, hãy thử tìm bằng câu trả lời.
A relational database developer refers to a record as:
Answer: A tuple.

In an E-R diagram attributes are represented by:
Answer: Ellipse

DBMS helps achieve:
Answer: Both (A) and (B).

In an E-R diagram double lines indicate
Answer: Total participation.

The DBMS acts as an interface between what two components of an enterprise-class database system?
Answer: Database application and the database

Which of the following is an accurate statement in regard to an E-R diagram?
Answer: It creates an abstraction of information handled in operations, so as to express entities and the relations between them.

A set of possible data values is called:
Answer: Domain

A table can have only one
Answer: Primary key

The file organization that provides very fast access to any arbitrary record of a file is:
Answer: Hashed file.

A relation is considered a:
Answer: two-dimensional table.

In a relation
Answer: both

The conceptual model is:
Answer: Independent of both hardware and software

Answer:

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 and the employee entity?
Answer: 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.

Which of the following is another name for weak entity?
Answer: Child

In case of entity integrity, the primary key may be:
Answer: Not Null

Answer:

Which of the following is the appropriate characteristic of a database?
Answer:It can be accessed by multiple users at the same time due to an exclusive control function.

Which option is not TRUE?
Answer: Neither (A) nor (B)

Which of the following is described graphically using an E-R diagram?
Answer: Entities and relationships between entities

An instance of relational schema R (A, B, C) has distinct values of A including NULL values. Which one of the following is true?
Answer: A is not a candidate key

Consider the join of a relation R with relation S. If R has m tuples and S has n tuples, then the maximum size of join is:
Answer: mn

When the data model is represented to conform to the notational convention shown below, which of the following statements appropriately interprets the designated E-R diagram?
Answer: It does not occur that a single order placement is given to multiple suppliers.

What is data integrity?
Answer: It is the data contained in database that is accurate and consistent.

The entity-relationship diagrams A and B shows the relationships between three entities in a school: teacher, class, and classroom. Which of the following is an appropriate interpretation concerning the diagrams? Here, " 1 1 " shows a one-to-one relationship while " 1 * " shows a one-to-many relationship.
Answer: In A, a teacher is responsible for one class only. In B, a teacher may be responsible for one or more classes

An advantage of the database management approach is:
Answer: Data is integrated and can be accessed by multiple programs.

It is better to use files than a DBMS when there are:
Answer: Multiple users wish to access the data.

NULL is:
Answer: Not a value

Answer: 1:1

Which of the following are the properties of entities?
Answer: Attributes

You are tasked with creating a database to manage where computers are installed at a company that has offices in several buildings. You create an “asset” table, a “room” table, and a “building” table, and link each of them together. When new data is entered, the data in the referenced table must already exist. Which of the following is the appropriate order of in-put? Here, the underlined items in each table are either primary or foreign keys.
Answer: “Building” table →“Room” table →“Asset” table

In the ERD diagram, the one-to-many relationship, "a company has multiple employees," is expressed as follows:
Answer: There are multiple companies, and each company has multiple shareholders.

If the condition given below applies, which of the following is appropriate as an E-R diagram showing the departments employees belong to?
Answer: Emp<-Dep

The values of the attribute describes a particular _____
Answer: Entity instance

In the relational modes, cardinality is termed as:
Answer: Number of tuples.

What is a relationship called when it is maintained between two entities?
Answer: Binary

Which of the following appropriately describes a domain (defined area), a term used for relational databases?
Answer: It is a set of values that attributes can hold.

The database environment has all of the following components except:
Answer: Users

An entity set that does not have sufficient attributes to form a primary key is a:
Answer: Weak entity set.

The method in which records are physically stored in a specified order according to a key field in each record
Answer: Hash

Which of the following appropriately describes a schema in a relational database management system?
Answer: It is a set of data definitions such as the data properties, format, relationship with other data, etc.

Which of the following is not a restriction for a table to be a relation?
Answer: The columns must be ordered.

The RDBMS terminology for a row is:
Answer: Tuple

Conceptual design
Answer: Involves modelling independent of the DBMS.

A DBMS query language is designed to:
Answer: All of the above.

Which of the following is expressed by an E-R diagram?
Answer: Relation between entities

In E-R diagram generalization is represented by
Answer: Triangle

Thứ Bảy, 22 tháng 10, 2016

ASQL Quiz


How many rows are included in the table gained as as result of execution of the following statement?
SELECT DISTINCT customer_name, merchandise_name, unit_price
FROM order_table, merchandise_table
WHERE order_table.merchandise_number = merchandise_table.mnrchandise_number
Answer: 2

How many tables may be included with a join?
Answer: All of the mentioned options

The IN SQL keyword?
Answer: Determines if a value matches any of the values in a list or a sub-query.

You have a Microsoft SQL Server 2012 database that contains tables named Customers and Orders. The tables are related by a column named CustomerID. You need to create a query that meets the following requirements:
Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.
Results must include customers who have not placed any orders.
Answer:"SELECT CustomerName, OrderDate
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID"

You have a table named Employees. You want to identify the supervisor to which each employee reports. You write the following query.

SELECT e.EmloyeeName AS [EmployeeName], s.EmployeeName AS [SuperVisorName] FROM Employees e

You need to ensure that the query returns a list of all employees and their respective supervisor. Which join clause should you use to complete the query?

Answer: LEFT JOIN Employees s ON e.ReportsTo = s.EmployeeId

The LIKE SQL keyword is used along with?
Answer: WHERE clause.

Which of the following is one of the basic approaches for joining tables?

Answer: All of the above (Subqueries, Union Join, Inner/Outer join)

There should be one condition within the WHERE clause for each pair of tables being joined.
Answer: True

In SQL language, one data manipulation command that combines the records from two tables is called
Answer: JOIN

A correlated sub-query is where the outer query depends on data from the inner query.
Answer: False

Which are the outputs of the below SQL statement on the two tables:
SELECT EmpName FROM EmpRoom
WHERE RoomID NOT IN (SELECT RoomID FROM RoomMgnt WHERE Department=’A1’)
Answer: Saito, Fukuda, Oohira

Which of the following relational algebra operations do not require the participating tables to be union-compatible?
Answer: Join

A UNION query is which of the following?
Answer: Combines the output from multiple queries and must include the same number of columns.

Subqueries can be nested multiple times
Answer: True

A CASE SQL statement is which of the following
Answer: A way to establish an IF-THEN-ELSE in SQL

A function returns one value and has only output parameters.
Answer: False

The joining technique is useful when data from several relations are to be retrieved and displayed and the relationships are not necessarily nested
Answer: True

Which of the following product groups can be found when searching the “Product Inventory” table for products with a sales price of 500 dollars or more per unit and an inventory of less than 10 units?
Answer: Medium refrigerator, small refrigerator, and air conditioner

You are a developer for a Microsoft SQL Server database instance used to support a customer service application. You create tables named complaint, customer, and product as follows:

CREATE TABLE [dbo].[complaint] ([ComplaintID] [int], [ProductID] [int], [CustomerID] [int], [ComplaintDate] [datetime]);

CREATE TABLE [dbo].[customer] ([CustomerID] [int], [CustomerName] [varchar](100), [Address] [varchar](200), [City] [varchar](100), [State] [varchar](50), [ZipCode] [varchar](5));

CREATE TABLE [dbo].[product] ([ProductID] [int], [ProductName] [varchar](100), [SalePrice] [money], [ManufacturerName] [varchar](100));

You need to write a query to identify all customers who have complained about products that have an average sales price of 500 or more from September 01, 2011.

Which SQL query should you use?
Answer: "SELECT c.CustomerName, AVG(p.SalePrice) AS Sales
FROM product p
INNER JOIN complaint com ON p.ProductID = com.ProductID
INNER JOIN customer c ON com.CustomerID = c.CustomerID
WHERE com.ComplaintDate > '09/01/2011'
GROUP BY c.CustomerName
HAVING AVG(p.SalePrice) >= 500"

The Enterprise manager cannot be used to modify stored procedures?
Answer: True

SQL triggers can be used when the DBMS receives a ____________request
Answer: All

You need to identify, within a given clause, if the month of February will contain 29 days for a specified year. Which object should you use?
Answer: Scalar-valued function

Which SQL trigger does SQL Server NOT support?
Answer: all

Which of the following statements is true concerning routines and triggers?
Answer: Both consist of procedural code.

Which of the following is true concerning triggers?
Answer: They have an event, condition, and action.

Using SQL Server 2000, which of the following symbols is used to indicate parameters in stored procedures?
Answer: @

The code to create triggers and routines is stored in only one location and is administered centrally.
Answer: True

A function returns one value and has only output parameters.
Answer: False

A _________________ is a program that performs some common action on database data and that is stored in the database
Answer: stored procedure

Which of the following is true concerning a procedure?
Answer: They include procedural and SQL statements

Because SQL stored procedures allow and encourage code sharing among developers, stored procedures give database application developers the advantages of__________
Answer: all

A _______________ is a stored program that is attached to a table or a view.
Answer: trigger

You have a third-party application that inserts data directly into a table. You add two new columns to the table. These columns cannot accept NULL values and cannot use default constraints. You need to ensure that the new columns do not break the third-party application. What should you do?
Answer: Create an INSTEAD OF INSERT trigger.

Which of the following is an SQL trigger Microsoft SQL Server supports?
Answer: INSTEAD OF and AFTER only

Which of the three possible types of triggers does SQL Server support?
Answer: INSTEAD OF and AFTER only

Stored procedures have the advantage of _______
Answer: all

You are tasked to create a table that has a column that must store the current time accurate to ten microseconds. You need to use a system function in conjunction with the DEFAULT option in the column definition. Which system function should you use?
Answer: SYSDATETIME

Which type of SQL Server cursor concurrency places an update lock on a row when the row is read?
Answer: READCOMMITTED

SQL triggers are created using _____
Answer: the SQL CREATE TRIGGER statement

In a relational database system, which of the following SQL statements is used to extract rows specified by the cursor after it has been defined?
Answer: FETCH statement

If a trigger is being written to enforce referential integrity actions, you cannot use______
Answer:  an AFTER trigger

The following SQL statement is curror B’s data manipulation for table A. Which is the correct character string to be entered in the blank?
UPDATE A SET A2=1, A3=2 WHERE ……………….
A(A1, A2, A3) is the structure of table A, the underline indicates the primary key
Answer: A1=CURRENT OF B (DON'T KNOW)

A stored program that is attached to the database is called ____
Answer: stored procedure

Triggers are stored blocks of code that have to be called in order to operate
Answer: False

SQL Server program code that is executed instead of an SQL command that needs to be processed is called a(n)
Answer: INSTEAD OF trigger.

Embedded SQL is which of the following?
Answer: Hard-coded SQL statements in a program language such as Java.

Because SQL statements are set-oriented, whereas programs are element-oriented, the results of SQL statements used in programs are accessed using_____
Answer: an SQL cursor

What is not an advantage of stored procedures?
Answer: Increased network traffic

SQL triggers are used for ____
Answer: ALL