Ibb Test SQL
Ibb Test SQL
Ibb Test SQL
Grup 3
Final Soruları (28.02.2023)
Ad:
Soyad:
Öğrenci No :
a. One-to-one relationship
b. One-to-many relationship
c. Many-to-many relationship
d. Many-to-one relationship
a. OPEN
b. FETCH
c. DECLARE CURSOR
d. @@FETCH_STATUS
a. Define, Create
b. Drop, Comment
c. Insert, Update, Delete
d. Select, Commit
4. Which of the following SQL command can be used to modify existing data in a database
table?
a. MODIFY
b. UPDATE
c. CHANGE
d. NEW
a. Outer
b. Inner
c. Equi
d. None of the Mentioned
6.You are a database developer for wide world importers. You are creating a database that will
store order information. Orders will be entered in a client/server application. Each time a new
order is entered, a unique order number must be assigned. Order numbers must be assigned in
ascending order. An average of 10, 000 orders will be entered each day.
You create a new table named Orders and add an OrderNumber column to this table. What
should you do next?
7.You are a database developer for a hospital. There are four supply rooms on each floor of the
hospital, and the hospital has 26 floors. You are designing an inventory control database for
disposable equipment. Certain disposable items must be kept stored at all times. As each item
is used, a barcode is scanned to reduce the inventory count in the database. The supply
manager should be paged as soon as a supply room has less than the minimum quantity of an
item. What should you do?
A. Create a stored procedure that will be called to update the inventory table. If the resultant
quantity is less than the restocking quantity, use the xp_logevent system stored procedure to
page the supply manager.
B. Create an INSTEAD OF UPDATE trigger on the inventory table. If the quantity in the inserted
table is less than the restocking quantity, use SQLAgentMail to send an e-mail message to the
supply manager’s pager.
C. Create a FOR UPDATE trigger on the inventory table. If the quantity in the inserted table is
less than the restocking quantity, use the xp_sendmail system stored procedure to page the
supply manager.
D. Schedule the SQL server job to run at four-hour intervals.
Configure the job to use the @notify_level_page = 2 argument.
Configure the job so that it tests each item’s quantity against the restocking quantity. Configure
the job so that it returns a false value if the item requires restocking.
This will trigger the paging of the supply manager.
8.You are a database developer for an insurance company. The insurance company has a multi-
tier application that is used to enter data about its policies and the owners of the policies. The
policy owner information is stored in a table named Owners. The script that was used to create
this table is shown in the exhibit.
CREATE TABLE Owners
(
OwnerID int IDENTITY (1, 1) NOT NULL,
FirstName char(20) NULL,
LastName char(30) NULL,
BirthDate date NULL,
CONSTRAINT PK_Owners PRIMARY KEY (Owner ID)
)
When information about policy owners is entered, the owner’s birth date is not included; the
database needs to produce a customized error message that can be displayed by the data entry
application. You need to design a way for the database to validate that the birth date is
supplied and to produce the error message if it is not.
What should you do?
9. You are the database developer for your company’s Accounting database. The database
contains a table named Employees. Tom is a member of the accounting department. Tom’s
database user account has been denied SELECT permissions on the Salary and BonusPercentage
columns of the Employees table. Tom has been granted SELECT permissions on all other
columns in the table. Tom now requires access to all the data in the Employees table.
What should you do?
A. Revoke SELECT permissions on the Salary and BonusPercentage columns of the Employees
table for
Tom’s database user account.
B. Add Tom to the db_datareader database role.
C. Add Tom to the db_accessadmin database role.
D. Grant SELECT permissions on the Salary and BonusPercentage columns of the Employees
table for Tom’s database user account.
10.You are a database developer for a hospital. You are designing a SQL Server database that
will contain physician and patient information. This database will contain a table named
Physicians and a table named Patients.Physicians treat multiple patients. Patients have a
primary physician and usually have a secondary physician. The primary physician must be
identified as the primary physician. The Patients table will contain no more than 2 million rows.
You want to increase I/O performance when data is selected from the tables. The database
should be normalized to the third normal form.
Which script should you use to create the tables?
NULL,
)
GO
CREATE TABLE Patients
(
PatientID bigint NOT NULL CONSTRAINT PK_Patients PRIMARY KEY CLUSTERED,
LastName varchar (25) NOT NULL,
FirstName varchar (25) NOT NULL,
PrimaryPhysician int NOT NULL,
SecondaryPhysician int NOT NULL,
CONSTRAINT PK_Patients_Physicians1 FOREIGN KEY (PrimaryPhysician) REFERENCES Physicians
(PhysicianID),
CONSTRAINT PK_Patients_Physicians2 FOREIGN KEY (SecondaryPhysician) REFERENCES
Physicians (PhysicianID)
)
B. CREATE TABLE Patients (
PatientID smallint NOT NULL CONSTRAINT PK_Patients PRIMARY KEY CLUSTERED, LastName
varchar(25) NOT NULL,
FirstName varchar (25) NOT NULL,
PrimaryPhysician int NOT NULL,
SecondaryPhysician int NOT NULL, )
GO
CREATE TABLE Physicians
(
PhysicianID smallint NOT NULL CONSTRAINT PK_Physicians PRIMARY KEY CLUSTERED,
LastName varchar (25) NOT
NULL,
FirstName varchar (25) NOT NULL,
CONSTRAINT PK_Physicians_Patients FOREIGN KEY (PhysicianID) REFERENCES Patients
(PatientID)
)
C. CREATE TABLE Patients (
PatientID bigint NOT NULL CONSTRAINT PK_Patients PRIMARY KEY CLUSTERED, LastName
varchar (25) NOT NULL,
FirstName varchar (25) NOT NULL,
)
GO
CREATE TABLE Physicians
(
PhysicianID int NOT NULL CONSTRAINT PK_Physician PRIMARY KEY CLUSTERED,
LastName varchar (25) NOT NULL,
FirstName varchar (25) NOT NULL,
)
GO
CREATE TABLE PatientPhysician
(
PatientPhysicianID bigint NOT NULL CONSTRAINT PK_PatientsPhysicians PRIMARY KEY
CLUSTERED,
PhysicianID int NOT NULL,
PatientID bigint NOT NULL,
PrimaryPhysician bit NOT NULL,
FOREIGN KEY (PhysicianID) REFERENCES Physicians (PhysicianID),
FOREIGN KEY (PatientID) REFERENCES Patients (PatientID)
)
D. CREATE TABLE Patients (
PatientID int NOT NULL PRIMARY KEY, LastName varchar (25) NOT NULL, FirstName varchar
(25) NOT NULL,
)
GO
CREATE TABLE Physicians
(
PhysicianID int NOT NULL PRIMARY KEY,
LastName varchar (25) NOT NULL,
FirstName varchar (25) NOT NULL,
)
GO
CREATE TABLE PatientPhysician
(
PhysicianID int NOT NULL REFERENCES Physicians (PhysicianID),
PatientID int NOT NULL REFERENCES Patients (PatientID), PrimaryPhysician bit NOT NULL,
CONSTRAINT
PK_PatientsPhysicians PRIMARY KEY (PhysicianID, PatientID)
)