Software Development Exam  >  Software Development Tests  >  Test: SQL Constraints - 2 - Software Development MCQ

Test: SQL Constraints - 2 - Software Development MCQ


Test Description

15 Questions MCQ Test - Test: SQL Constraints - 2

Test: SQL Constraints - 2 for Software Development 2024 is part of Software Development preparation. The Test: SQL Constraints - 2 questions and answers have been prepared according to the Software Development exam syllabus.The Test: SQL Constraints - 2 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: SQL Constraints - 2 below.
Solutions of Test: SQL Constraints - 2 questions in English are available as part of our course for Software Development & Test: SQL Constraints - 2 solutions in Hindi for Software Development course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: SQL Constraints - 2 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study for Software Development Exam | Download free PDF with solutions
Test: SQL Constraints - 2 - Question 1

Which of the following best describes a primary key constraint in SQL?

Detailed Solution for Test: SQL Constraints - 2 - Question 1

A primary key constraint is used to define a column or a set of columns that uniquely identifies each row in a table.

Test: SQL Constraints - 2 - Question 2

What is the purpose of a foreign key constraint in SQL?

Detailed Solution for Test: SQL Constraints - 2 - Question 2

A foreign key constraint is used to establish a relationship between two tables by referencing the primary key of one table in another table.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: SQL Constraints - 2 - Question 3

Which of the following constraints enforces a column or a set of columns to have unique values within a table?

Detailed Solution for Test: SQL Constraints - 2 - Question 3

The unique constraint enforces a column or a set of columns to have unique values within a table.

Test: SQL Constraints - 2 - Question 4

What does the check constraint do in SQL?

Detailed Solution for Test: SQL Constraints - 2 - Question 4

A check constraint imposes a condition that must be satisfied by the values in a column.

Test: SQL Constraints - 2 - Question 5

Which of the following constraints allows you to provide a default value for a column if no value is specified during an insertion?

Detailed Solution for Test: SQL Constraints - 2 - Question 5

The default constraint allows you to provide a default value for a column if no value is specified during an insertion.

Test: SQL Constraints - 2 - Question 6

Consider the following SQL table definition:

CREATE TABLE Employees (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    DepartmentID INT FOREIGN KEY REFERENCES Departments(ID)
);
What would be the output of the following INSERT statement?

INSERT INTO Employees (ID, Name, DepartmentID) VALUES (1, 'John Doe', 100);

Detailed Solution for Test: SQL Constraints - 2 - Question 6

The DepartmentID value 100 does not exist in the referenced table Departments(ID), resulting in a foreign key violation.

Test: SQL Constraints - 2 - Question 7

Consider the following SQL table definition:
CREATE TABLE Orders (
    OrderID INT PRIMARY KEY,
    OrderDate DATE DEFAULT GETDATE()
);
What would be the output of the following INSERT statement?

INSERT INTO Orders (OrderID) VALUES (1);

Detailed Solution for Test: SQL Constraints - 2 - Question 7

The OrderDate column has a default value of GETDATE(), which returns the current date.

Test: SQL Constraints - 2 - Question 8

Consider the following SQL table definition:

CREATE TABLE Students (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    Age INT CHECK (Age > 0)
);
What would be the output of the following INSERT statement?

INSERT INTO Students (ID, Name, Age) VALUES (1, 'Alice', 18);

Detailed Solution for Test: SQL Constraints - 2 - Question 8

The INSERT statement satisfies all the constraints, including the primary key and the check constraint.

Test: SQL Constraints - 2 - Question 9

Consider the following SQL table definition:

CREATE TABLE Employees (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    DepartmentID INT,
    CONSTRAINT FK_Department FOREIGN KEY (DepartmentID) REFERENCES Departments(ID)
);
What would happen if the following DELETE statement is executed?

DELETE FROM Departments WHERE ID = 1;

Detailed Solution for Test: SQL Constraints - 2 - Question 9

The Departments table has a foreign key constraint on the ID column, referenced by the Employees table. Therefore, deleting a row in the Departments table will result in a foreign key violation.

Test: SQL Constraints - 2 - Question 10

Consider the following SQL table definition:

CREATE TABLE Customers (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    Discount DECIMAL(4, 2) DEFAULT 0.00 CHECK (Discount >= 0 AND Discount <= 1)
);
Which of the following statements about the Customers table is correct?

Detailed Solution for Test: SQL Constraints - 2 - Question 10

The given statements about the Customers table are all correct.

Test: SQL Constraints - 2 - Question 11

Consider the following SQL table definition:

CREATE TABLE Orders (
    OrderID INT PRIMARY KEY,
    CustomerID INT FOREIGN KEY REFERENCES Customers(ID),
    OrderDate DATE DEFAULT GETDATE()
);
Which of the following statements about the Orders table is correct?

Test: SQL Constraints - 2 - Question 12

Consider the following SQL table definition:

CREATE TABLE Products (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    Price DECIMAL(10, 2) CHECK (Price > 0),
    CategoryID INT,
    CONSTRAINT FK_Category FOREIGN KEY (CategoryID) REFERENCES Categories(ID)
);
Which of the following statements about the Products table is correct?

Detailed Solution for Test: SQL Constraints - 2 - Question 12

The CategoryID column in the Products table is a foreign key referencing the ID column in the Categories table.

Test: SQL Constraints - 2 - Question 13

Consider the following SQL table definition:

CREATE TABLE Orders (
    OrderID INT PRIMARY KEY,
    OrderDate DATE,
    CustomerID INT,
    CONSTRAINT FK_Customer FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE CASCADE
);
What happens when a customer is deleted from the Customers table?

Detailed Solution for Test: SQL Constraints - 2 - Question 13

The foreign key constraint in the Orders table is defined with ON DELETE CASCADE, which means that deleting a customer will delete all corresponding rows in the Orders table.

Test: SQL Constraints - 2 - Question 14

Consider the following SQL table definition:

CREATE TABLE Employees (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    ManagerID INT,
    CONSTRAINT FK_Manager FOREIGN KEY (ManagerID) REFERENCES Employees(ID)
);
Which type of relationship is represented by the foreign key constraint in this table?

Detailed Solution for Test: SQL Constraints - 2 - Question 14

The foreign key constraint in the Employees table establishes a many-to-one relationship, where multiple employees can have the same manager.

Test: SQL Constraints - 2 - Question 15

Consider the following SQL table definition:

CREATE TABLE Employees (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    ManagerID INT,
    CONSTRAINT FK_Manager FOREIGN KEY (ManagerID) REFERENCES Employees(ID) ON UPDATE CASCADE
);
What happens when the ID of a manager is updated in the Employees table?

Detailed Solution for Test: SQL Constraints - 2 - Question 15

When the ID of a manager is updated in the Employees table, all employees who had the previous manager will have their ManagerID updated accordingly.

Information about Test: SQL Constraints - 2 Page
In this test you can find the Exam questions for Test: SQL Constraints - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: SQL Constraints - 2, EduRev gives you an ample number of Online tests for practice

Top Courses for Software Development

Download as PDF

Top Courses for Software Development