Pergunta de entrevista da empresa DevNatives

1. What is the difference between WHERE and HAVING Clause? And when we use where or Having explain with an example? 2. Write a query to find 3rd Maximum salary ? (Easy one) 3. Explain Normalization Types? 4. What is the difference between OLAP and OLTP? 5. Interviewer Provide me a scenario for query writing, I think it was like " Find those employees whos Average salary is greater than 100k department wise" 6. What is the difference between Union and Union ALL? 7. What is the difference between Delete and Truncate statement? 8. Difference between Fact and Dimensions? 9. Different type of Joins? 10. Types of SCD with Example?

Resposta da entrevista

Sigiloso

17 de jan. de 2021

1. a. Where is row level filter while Having is a column level filter. b. We can used where with Delete statement but we can't use Having with Delete statement c. We use Having when we are using any aggregate function like Sum Count Avg etc. Yes, we can use Where with Having. For this, First we use Where and than we use Having Statement. 2. Select min (Salary) From Employee Where Salary in ( Select Distinct TOP 3 Salary From Employee order by Salary DESC ) 3. Normally, We use 3 types of Normalization 1NF: As per the rule of first normal form, an attribute (column) of a table cannot hold multiple values. It should hold only atomic values. 2NF: Remove Partial Dependencies Table is in 1NF (First normal form) No non-prime attribute is dependent on the proper subset of any candidate key of table. 3NF: Remove Transitive property It is in the Second Normal form. And, it doesn't have Transitive Dependency. 4. a. OLAP Stands for Online Analytical processing and OLTP Stands for Online Transactional Processing b. Tables in OLTP database are normalized. Tables in OLAP database are not normalized. c. OLTP helps to control and run fundamental business tasks. OLAP helps with planning, problem-solving, and decision support. d. OLTP is designed to have fast response time, low data redundancy and is normalized. OLAP A data warehouse is created uniquely so that it can integrate different data sources for building a consolidated database 5. I exactly don't remember the scenario but query includes two table joins having clause and group by clause 6. The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all the rows. While, UNION eliminate duplicate rows. 7. a. TRUNCATE is a DDL command . DELETE is a DML command. b. We cannot use the WHERE clause with TRUNCATE. We can use where clause with DELETE to filter & delete specific records. c. Truncate: Minimal logging in the transaction log, so it is faster performance-wise. Delete : It maintains the log, so it slower than TRUNCATE. d. Truncate cannot be used with indexed views. The delete can be used with indexed views. 8. a. Fact: It contains all the primary keys of the dimension and associated facts or measures(is a property on which calculations can be made) like quantity sold, amount sold and average sales. Dimension: Dimension tables provides descriptive information for all the measurements recorded in fact table b. Dimensions are relatively very small as comparison of fact table. 9. (INNER) JOIN: Returns records that have matching values in both tables LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table 10. Type 1 : Overwriting the old value SCD type 1 methodology is used when there is no need to store historical data in the dimension table. This method overwrites the old data in the dimension table with the new data. Type 2 : Creating a new additional record SCD type 2 stores the entire history the data in the dimension table. With type 2 we can store unlimited history in the dimension table. In type 2, you can store the data in three different ways. They are Versioning Flagging Effective Date Type 3 : Adding a new column In type 3 method, only the current status and previous status of the row is maintained in the table. To track these changes two separate columns are created in the table.