1. What is a Relational Database Management System?
A Relational Database Management System (RDBMS) refers to the software used to store, manage, and query data. Data is stored in tables and can be linked to other datasets based on shared information, hence the name “relational”.
2. How does a Relational Database Management System differ from a Database Management System?
The key differences between Relational Database Management Systems (RDBMS) and Database Management Systems (DBMS) are:
An RDBMS stores data in a relational table with rows and columns, whereas a DBMS stores data as a file
An RDBMS provides access to multiple users (including client-server side interaction), whereas a DBMS only supports single users
3. What are some of the most popular Relational Database Management Systems?
Some of the most popular RDBMSs are:
4. What is SQL?
SQL is a programming language used to perform data-related tasks; every RDBMS uses SQL as its standard programming language. In these databases, SQL allows users to create tables, update data, make queries, and perform analytics.
5. What is the difference between SQL and MySQL?
SQL is the programming language used in an RDBMS, while MySQL is an example of an RDBMS. MySQL was one of the first open-source database systems on the market, and it is still fairly popular today.
6. How do you create a table with SQL?
The CREATE TABLE command is used to create a new table in an RDBMS. This command prompts users to fill in the table name, the column names, and the types of data. The same command can also be used to make copies of existing tables.
7. What is a query?
A query is a request for data or information from a database. There are two main types of SQL queries:
A select query is a query that groups data from a table for analytical purposes
An action query is a query that changes the contents of the database based on specified criteria
8. What is a subquery?
A subquery is a query that is embedded within another statement that requires multiple steps. The subquery provides the enclosing query with additional information needed to execute a task, such as when the completion of one query depends firstly on the results of another.
9. How do you perform a select query with SQL?
The process for performing a select query in SQL is as follows:
10. What are the most important types of action queries?
There are several SQL statements for running an action query. Their purposes and procedures vary. Some of the important action statements include:
11. What are constraints?
SQL constraints are a set of rules or conditions implemented on an RDBMS to specify what data can be inserted, updated, or deleted in its tables. This is done to maintain data integrity and ensure that the information stored in database tables is accurate.
12. What are the different types of SQL commands?
SQL commands are used to perform specific tasks within the database. There are five main types:
13. What is an alias?
Aliases are temporary names given to tables or columns for the duration of a particular SQL query. Their purpose is to reduce the amount of code required for that query, therefore saving time and effort.
14. What is cursor in SQL?
The cursor allows users to process data from a result set, one row at a time.
Cursors are an alternative to commands, which operate on all rows in a result set at the same time. Unlike commands, cursors can be used to update data on a row-by-row basis.
15. What are the key differences between the DELETE and TRUNCATE SQL commands?
The main differences between the DELETE and TRUNCATE commands are:
DELETE is a DML command, whereas TRUNCATE is a DDL command
DELETE removes records and records each deletion in the transaction log, whereas TRUNCATE deallocates pages and records each deallocation in the transaction log
TRUNCATE is generally considered quicker as it makes less use of the transaction log.
16. How do you delete a column?
A column in a table can be deleted by following these steps:
17. How would you write a SQL query to find entrants whose names begin with A?
Use the SELECT statement to specify the column with the names you want to vet
Use the FROM statement to specify the table containing that column
Use ‘WHERE column name’ followed by ‘LIKE x%’, with x representing the letter you are searching for
Use ‘ORDER by column name’ to complete the query
Ex: select * from employee where emp_name (LIKE 'A%');
18. What is Schema?
A schema refers to a collection of database objects—such as tables, functions, indexes, and procedures—associated with a database.
The schema helps segregate database objects for different applications and access rights; it’s generally used to define who can and who cannot view specific objects in the database.
19. Write a query to find employees with the same salary from an employee table?
To find employees with the same salary, the following solution can be used:
‘WHERE salary IN
(SELECT salary
FROM employee
WHERE employee.employee_id <> employee.employee_id)’
20. How do you remove duplicate rows from a table?
There are several ways to remove duplicate rows from a table. These include: