Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

DBMS Important Questions CIA2

2Marks

• Candidate Key
o It is a set of attributes that uniquely identify tuples in a table.
o It is a super key with no repeated attributes.
• Super Key
o A super key is a group of single or multiple keys which identifies rows in a table.
• Surrogate Key
o Surrogate keys is an artificial key which aims to uniquely identify each record.
• History of Normalization [PG 44-48 IF 10M] [Unit-2]
• 1NF [10M PG55-63]
• Origin of SQL
o SQL (Structured Query Language) was first developed in the early 1970s by Donald D. Chamberlin
and Raymond F. Boyce at IBM. It was originally called SEQUEL (Structured English Query Language)
and was designed to manipulate and retrieve data stored in IBM's original relational database
management system, called System R.
• Any one query
o SELECT * FROM customers WHERE country = 'USA';
o This query selects all columns from the "customers" table where the "country" column equals 'USA'.

6Marks

• Types of SQL commands with Schema diagram

Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL),

Transaction Control Language (TCL), Data Query Language (DQL)

There are five types of SQL commands:


Data Definition Language (DDL): DDL commands are used to define, modify, and delete database objects such as
tables, views, indexes, and procedures. Some of the commonly used DDL commands are:

CREATE: used to create a new database object

ALTER: used to modify an existing database object

DROP: used to delete an existing database object

TRUNCATE: used to remove all data from a table without deleting the table itself

Data Manipulation Language (DML): DML commands are used to manipulate data stored in the database. Some of
the commonly used DML commands are:

SELECT: used to retrieve data from one or more tables

INSERT: used to insert new data into a table

UPDATE: used to modify existing data in a table

DELETE: used to delete data from a table

Data Control Language (DCL): DCL commands are used to control access to the database. Some of the commonly
used DCL commands are:

GRANT: used to grant permissions to a user or role

REVOKE: used to revoke permissions from a user or role

Transaction Control Language (TCL): TCL commands are used to manage transactions in the database. Some of the
commonly used TCL commands are:

COMMIT: used to save changes made to the database

ROLLBACK: used to undo changes made to the database

SAVEPOINT: used to create a savepoint within a transaction

Data Query Language (DQL): DQL commands are used to retrieve data from the database. The most commonly used
DQL command is SELECT, which is used to retrieve data from one or more tables based on specified criteria.

Overall, these SQL commands are used to create, modify, delete, manipulate, control access to, and query data from
a database. Understanding these commands is essential for working with databases and SQL.

• Super Key and Explain


In relational database management systems (RDBMS), a super key is a set of one or more attributes (or columns)
that uniquely identifies each row (or record) in a table. A super key can be thought of as a combination of attributes
that can be used to identify a unique row in the table.

For example, let's say we have a table named "students" with the following columns:

student_id

first_name

last_name

email

phone_number

If the student_id column is a primary key, it uniquely identifies each row in the students table. However, if we use a
combination of columns such as first_name and last_name, or email and phone_number, then we have a super key.

In this case, the combination of first_name and last_name columns may not be unique by itself, but when combined,
it can uniquely identify each row in the table. Similarly, the combination of email and phone_number may also serve
as a super key, as it can uniquely identify each student.

A super key can be either a candidate key or a composite key. A candidate key is a minimal super key, which means it
cannot be reduced further without losing its uniqueness property. A composite key, on the other hand, is a
combination of multiple attributes that together serve as a super key.

For example, let's consider a table named "orders" with the following columns:
order_id

customer_id

order_date

order_total

Here, the order_id column is a primary key, which uniquely identifies each row in the table. However, the
combination of customer_id and order_date can also uniquely identify each row in the table, making it a composite
super key.

In summary, a super key is a set of one or more attributes that can uniquely identify each row in a table. It can be a
candidate key or a composite key, and is used in database design to ensure data integrity and accuracy.

• History of SQL

1970s: Donald D. Chamberlin and Raymond F. Boyce develop a prototype language for manipulating and
querying relational databases, which is later renamed to SQL.
1974: The first version of SQL is released and used internally at IBM.
Late 1970s - early 1980s: SQL gains popularity among other companies and organizations adopting relational
database technology.
1986: The American National Standards Institute (ANSI) establishes a standard for SQL, further solidifying its
popularity and widespread adoption.
1989: ANSI releases a revised version of the SQL standard, known as SQL-89, adding support for views,
integrity constraints, and transactions.
1992: ANSI releases SQL-92, a major update to the standard adding support for more advanced features
such as outer joins and subqueries.
1999: ANSI releases SQL:1999, which adds support for object-relational features such as user-defined types
and functions.
2003: ANSI releases SQL:2003, which adds support for recursive queries, window functions, and more.
2008: ANSI releases SQL:2008, which adds support for spatial data and time zones.
2011: ANSI releases SQL:2011, which adds support for temporal data.
Today: SQL is one of the most widely used programming languages in the world, used by developers and
database administrators to manage and manipulate data in relational databases. Its popularity is due in part
to its ease of use and flexibility, as well as its ability to handle large volumes of data efficiently.

10Marks

• Explain Natural Join, Self-Join.


• History of Normalization
• 1NF
• SQL Query Functions
o MAX, MIN, SUM, AVG, ORDER BY, IN, NOT IN, ANY
• Explain relational operators and logical operators

Yes, SQL uses both relational and logical operators to perform various operations on data.

Relational operators in SQL are used to compare values between two or more columns in a table. The most
commonly used relational operators in SQL are:
= (equal to)

<> or! = (not equal to)

< (less than)

(Greater than)

<= (less than or equal to)

= (greater than or equal to)

Logical operators in SQL are used to combine multiple conditions together to form more complex conditions.
The most commonly used logical operators in SQL are:

AND: used to combine multiple conditions together, where all conditions must be true for the expression to
be true.

OR: used to combine multiple conditions together, where at least one condition must be true for the
expression to be true.

NOT: used to negate a condition, where the expression is true if the condition is false.

For example, the following SQL query uses both relational and logical operators to retrieve data from a table:

SELECT * FROM customers WHERE age > 18 AND gender = 'female';

In this query, the relational operator ">" is used to compare the "age" column to the value 18, and the
relational operator "=" is used to compare the "gender" column to the value "female". The logical operator
"AND" is used to combine these two conditions together, so that the query returns only those rows where
the "age" column is greater than 18 and the "gender" column is "female".

You might also like