0% found this document useful (0 votes)
8 views5 pages

DBMS 2

The document provides an overview of Database Management Systems, focusing on data normalization and SQL. It explains the benefits of normalization, the different normal forms, and various SQL sub-languages and clauses. Additionally, it includes a quiz section to test knowledge on SQL concepts and database integrity.

Uploaded by

Anjo Villar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

DBMS 2

The document provides an overview of Database Management Systems, focusing on data normalization and SQL. It explains the benefits of normalization, the different normal forms, and various SQL sub-languages and clauses. Additionally, it includes a quiz section to test knowledge on SQL concepts and database integrity.

Uploaded by

Anjo Villar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Database Management System – Reviewer

Data Normalization Introduction to SQL

Normalization is the process of organizing data SQL (Structured Query Language) is used for
to minimize redundancy and ensure data managing and manipulating relational
integrity. databases. It consists of several sub-languages:

Benefits of Normalization:  DDL (Data Definition Language): Used


to define the structure of the database.
1. Reduces Data Redundancy.
o CREATE: Creates a new table,
2. Improves Data Integrity.
database, or view.
3. Prevents Update Anomalies.
o DROP: Deletes tables or
4. Simplifies Queries. databases.

Normal Forms: o ALTER: Modifies the structure


of a table.
 First Normal Form (1NF): Ensures that
the values in each column are atomic  DML (Data Manipulation Language):
and that each record is unique. Manages the data in the tables.

o To achieve 1NF, eliminate o INSERT INTO: Adds new records


duplicate records and break to a table.
down multivalued attributes
o SELECT: Retrieves data from the
into separate records.
database.
 Second Normal Form (2NF): Builds on
o UPDATE: Modifies existing
1NF and removes partial dependencies;
records.
each non-key attribute must depend on
the whole primary key. o DELETE: Removes records from
a table.
o Achieved by ensuring all non-
key attributes are fully  DCL (Data Control Language): Deals
dependent on the primary key. with rights, permissions, and other
controls.
 Third Normal Form (3NF): Builds on
2NF and eliminates transitive o GRANT: Assigns user access
dependencies, where non-key rights.
attributes depend on other non-key
attributes. o REVOKE: Removes user access
rights.
o Achieved by ensuring that
attributes are only dependent  TCL (Transaction Control Language):
on the primary key. Manages transactions.

o COMMIT: Saves all the


transactions permanently.

o ROLLBACK: Undoes a
transaction.
Database Management System – Reviewer

Key SQL Clauses QUIZ

 WHERE: Filters records based on a 1. Which of the following statements is


condition. true regarding a FOREIGN KEY in SQL?
a) It must refer to a unique value in the
 GROUP BY: Groups rows that have the
referenced table.
same values into summary rows.
b) It automatically generates values for
 HAVING: Filters records after GROUP the related column.
BY. c) It cannot reference a column from
the same table.
 ORDER BY: Sorts the result set by one d) It must always be a primary key in
or more columns. the referencing table.
Data Types in SQL: 2. What happens if a record is deleted
from a table that has a FOREIGN KEY
 NUMERIC(P,S): Fixed-point numbers relationship with another table?
(e.g., NUMERIC(8,2)). a) The referencing record is
 INTEGER: Whole numbers. automatically deleted.
b) The delete action is rejected unless
 CHAR(L): Fixed-length string. ON DELETE CASCADE is set.
c) The FOREIGN KEY is automatically
 VARCHAR(L): Variable-length string.
removed.
 DATE: Date format. d) The record in the referencing table is
updated to NULL.
Referential Integrity:
3. Which SQL clause allows you to filter
 PRIMARY KEY: Uniquely identifies each records after they have been
record. aggregated?
a) WHERE
 FOREIGN KEY: Establishes a relationship b) HAVING
between two tables. c) GROUP BY
Common Aggregate Functions: d) ORDER BY
4. Which SQL function is used to find the
 COUNT: Returns the number of rows. difference in dates between two date
 SUM: Returns the sum of a column. columns?
a) DATE_DIFF
 AVG: Returns the average value. b) DATEDIFF
c) DATE_ADD
 MIN/MAX: Returns the minimum or
d) TIMEDIFF
maximum value.
5. When should the DISTINCT keyword be
Views: used in a SELECT statement?
a) When you need to filter records
 A view is a virtual table based on the
based on a condition.
result set of a SQL query.
b) When there are multiple joins in the
o CREATE VIEW allows creating a query.
view. c) When duplicates need to be removed
from the result set.
Database Management System – Reviewer

d) When sorting results by a specific maximum defined storage space, while


column. VARCHAR only uses as much space as
6. Which of the following is true about a necessary.
VIEW in SQL? b) VARCHAR is used for fixed-length
a) It is a temporary table that stores strings, while CHAR is for variable-
data physically. length strings.
b) It cannot contain any joins or c) CHAR allows for text indexing, but
subqueries. VARCHAR does not.
c) It is a virtual table created by a query. d) There is no difference; they function
d) It automatically updates its data after exactly the same.
every transaction. 11. Which of the following best defines a
7. In SQL, what is the result of executing a composite key in a relational
FULL OUTER JOIN between two tables database?
without any matching rows? a) A key that consists of a single unique
a) Only the matching rows are returned. column.
b) All records from both tables are b) A primary key that references
returned, with NULLs for non-matching multiple columns in a foreign table.
columns. c) A key made up of more than one
c) No rows are returned. column, where each column can be a
d) The query fails due to the lack of primary key.
matching rows. d) A key that uses multiple columns to
8. How does the INSERT INTO ... SELECT uniquely identify a record.
statement function in SQL? 12. In a LEFT JOIN between two tables,
a) It allows the insertion of new which records are returned?
columns into a table. a) Only the records that match from
b) It copies data from one table into both tables.
another existing table. b) All records from the left table, and
c) It updates existing rows in the matching records from the right table.
destination table. c) Only records from the left table.
d) It creates a new table from the d) All records from both tables, whether
selected query result. they match or not.
9. What is the primary purpose of 13. Which statement best describes
TRUNCATE over DELETE in SQL? referential integrity in a relational
a) TRUNCATE can selectively remove database?
records based on conditions. a) It ensures every foreign key
b) TRUNCATE is faster as it does not log corresponds to a primary key in another
individual row deletions. table.
c) TRUNCATE always retains the original b) It prevents two columns from having
structure of the table. the same value in different tables.
d) TRUNCATE is used to archive records c) It guarantees that every record in a
before deletion. table has a unique primary key.
10. What is a major distinction between d) It ensures that database updates are
CHAR and VARCHAR data types in SQL? automatically logged.
a) CHAR always consumes the
Database Management System – Reviewer

14. What does the COUNT(*) function do 19. Which of the following statements
in SQL? about database indexes is true?
a) It counts all non-null values in a a) Indexes are only created on primary
column. key columns.
b) It counts the number of unique b) Indexes improve the speed of data
values in a column. retrieval operations.
c) It returns the number of rows in a c) Indexes must be rebuilt every time a
table, including those with NULL values. table is modified.
d) It counts only rows that meet a d) Indexes consume less disk space than
specific condition. the original table data.
15. What does a schema in a relational 20. In SQL, which of the following is a valid
database represent? way to rename an existing table?
a) A specific record or entry within a a) ALTER TABLE table_name RENAME
table. TO new_table_name;
b) The physical storage of database files b) MODIFY TABLE table_name RENAME
on disk. new_table_name;
c) A collection of tables, views, and c) RENAME TABLE table_name TO
other database objects. new_table_name;
d) A SQL query that has been stored for d) CREATE TABLE new_table_name AS
later execution. SELECT * FROM table_name;
16. Which of the following commands 21. What is the effect of ON DELETE
removes both table structure and its CASCADE in a FOREIGN KEY constraint?
data permanently? a) The referenced record will be
a) DELETE archived before deletion.
b) TRUNCATE b) All associated records in the
c) DROP referencing table are also deleted.
d) ALTER c) The deletion is canceled if any
17. When would you use the GROUP BY referencing records exist.
clause in a SQL query? d) The deletion will fail if the referenced
a) When sorting data alphabetically. key is part of a composite key.
b) When combining rows based on a 22. Which of the following SQL commands
shared column value for aggregation. creates a new index?
c) When filtering records using a a) CREATE UNIQUE INDEX
specific condition. b) ADD INDEX
d) When removing duplicate rows from c) ALTER TABLE ADD INDEX
a result set. d) CREATE INDEX ON TABLE
18. Which normalization form addresses 23. When normalizing a database to 3NF,
partial dependency issues in a what must be eliminated?
relational database? a) Partial dependencies
a) First Normal Form (1NF) b) Multivalued attributes
b) Second Normal Form (2NF) c) Transitive dependencies
c) Third Normal Form (3NF) d) Non-key attributes
d) Boyce-Codd Normal Form (BCNF) 24. In SQL, what does the HAVING clause
allow that the WHERE clause does not?
Database Management System – Reviewer

a) Filtering on aggregated data. a) It reduces the size of the database.


b) Sorting results in ascending order. b) It improves the performance of read-
c) Filtering NULL values. heavy queries.
d) Limiting the number of returned c) It prevents duplicate data in the
rows. database.
25. Which SQL clause would you use to d) It ensures all data dependencies are
limit the number of rows returned by a fully maintained.
query? 30. When performing normalization, what
a) LIMIT does it mean if a table is in Boyce-Codd
b) TOP Normal Form (BCNF)?
c) ROWCOUNT a) It has no repeating groups or arrays.
d) FETCH b) Every determinant is a candidate key.
26. Which of the following statements c) All non-key attributes depend on the
best describes a UNION in SQL? whole primary key.
a) It combines two tables into one and d) Transitive dependencies have been
returns all unique records. removed.
b) It combines columns from different
tables.
c) It merges the columns of two tables
with the same number of rows.
d) It performs an inner join on two
tables and returns all records.
27. Which of the following best defines a
candidate key in a database?
a) A column or combination of columns
that uniquely identifies a record.
b) The foreign key in a one-to-many
relationship.
c) A key that can be both primary and
foreign at the same time.
d) A column that allows duplicate
values.
28. In the context of relational databases,
what is a join operation used for?
a) To combine rows from multiple
tables based on a related column.
b) To remove rows with NULL values
from a table.
c) To filter records based on specific
conditions.
d) To create a new table from existing
rows.
29. Which of the following is an advantage
of denormalization?

You might also like