Category Archives: Database Systems - Page 2

Clustered vs Nonclustered Index

Question What is the difference between clustered and non clustered database index Answer A database index is a special data structure (tree, hash, etc) that improves the performance of data retrieval. There is nothing free so the performance gain comes …

Read more »

Where vs Having SQL

Question What is the difference between WHERE and HAVING clauses. Answer The WHERE clause restricts which rows are returned while the HAVING clause operates on groups of rows. HAVING is always used with GROUP BY and must have a function …

Read more »

Sql Views Advantages

Question What is a database view. Mention few database sql views advantages Answer A view is a virtual table (not part of the physical schema) composed from the result set of a stored query. Views contain dynamic content. This means if you modify the physical …

Read more »

Database Relationships Explained

Question I was asked this question in an interview. How do you implement one-to-one, one-to-many, and many-to-many relationships while designing tables Answer one-one relationship is most likely forced by business rules but it does not flow naturally from the data. …

Read more »

SQL All Keyword

All Keyword in SQL Given the following database table: employee(emp_name, emp_salary) write an SQL statement to print the employee name with the highest salary Solution Using the max aggregate function will give us the maximum salary but it does not …

Read more »

SQL Having Clause

Problem You have the following database table: employee (emp_name, emp_age, emp_department) Write an SQL statement to calculate the average age of employees who are older than 30 years old for each department. Do not display the average if the number …

Read more »

Sql unique distinct select

Problem Write code to simulate the SQL statement “Select unique emp_name from employees” Solution Assuming we have an array of employee names we need to write a function that prints the unique employee names in the array. We can use …

Read more »

Page 2 of 3123