![profile pic](https://preparesh-arbpfvdsfpcdg8a0.z01.azurefd.net/images/companies/profile/google.png)
![profile pic](https://preparesh-arbpfvdsfpcdg8a0.z01.azurefd.net/images/companies/profile/google.png)
You are given a database containing customer orders. The database currently has redundant and repetitive data, leading to inconsistency and excess storage usage. Explain how you would apply normalization techniques to this database. What specific steps would you take to achieve Third Normal Form (3NF)? Provide example tables before and after normalization.
Please sign-in to view the solution
In the context of database systems, explain the different kinds of schemas that could be used. Provide examples of each schema type to illustrate their use.
Please sign-in to view the solution
Explain what machine learning is and how it helps us to train data. Include examples of different types of machine learning and their typical applications.
Please sign-in to view the solution
Given the following Sales
table in a SQL database, write queries to: (1) Calculate the cumulative sales amount for each salesperson, ordered by SaleDate
; and (2) Find the average sales amount over a rolling window of the last 3 sales for each salesperson.
Sales Table:
| SaleID | SalespersonID | SaleAmount | SaleDate |
|--------|---------------|------------|-----------|
| 1 | 101 | 100 | 2023-01-01|
| 2 | 102 | 200 | 2023-01-02|
| 3 | 101 | 150 | 2023-01-03|
| 4 | 102 | 250 | 2023-01-04|
| 5 | 101 | 200 | 2023-01-05|
| 6 | 101 | 300 | 2023-01-06|
Please sign-in to view the solution
When is it appropriate to use mean versus median in data analysis? Provide specific examples where one measure may be preferred over the other.
Please sign-in to view the solution
Given the following Orders
and Customers
tables, write a SQL query to calculate the total amount spent by each customer. The result should include the CustomerID
, CustomerName
, and TotalAmountSpent
.
Orders Table:
| OrderID | CustomerID | OrderAmount | OrderDate |
|---------|------------|-------------|------------|
| 1 | 101 | 250 | 2023-01-01 |
| 2 | 102 | 150 | 2023-01-03 |
| 3 | 101 | 100 | 2023-01-04 |
| 4 | 103 | 200 | 2023-01-06 |
| 5 | 102 | 50 | 2023-01-07 |
Customers Table:
| CustomerID | CustomerName |
|------------|--------------|
| 101 | John Doe |
| 102 | Jane Smith |
| 103 | Bob Johnson |
Please sign-in to view the solution
Given the following two SQL queries, recommend improvements to each query and determine which query would run faster.
Sample Queries:
Query A:
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderAmount, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID WHERE Orders.OrderDate >= '2023-01-01';
Query B:
SELECT o.OrderID, c.CustomerName, o.OrderAmount, o.OrderDate FROM Orders o INNER JOIN Customers c ON o.CustomerID = c.CustomerID WHERE o.OrderID IN (SELECT OrderID FROM Orders WHERE OrderDate >= '2023-01-01');
Please sign-in to view the solution
How do you write a query to calculate the Root Mean Square Error (RMSE) in SQL? Assume you have two columns, Actual
and Predicted
, in a table called Predictions
.
Please sign-in to view the solution
Write a SQL query that combines the use of JOINs and analytical functions. Assume we have two tables: Sales
and Employees
. The query should calculate the total sales for each employee, and also rank the employees based on their total sales amount within each department. The result should include EmployeeID
, EmployeeName
, Department
, TotalSales
, and SalesRank
.
Tables:
**Sales Table**:
| SaleID | EmployeeID | SaleAmount | SaleDate |
|--------|------------|------------|-----------|
| 1 | 101 | 500 | 2023-01-01|
| 2 | 102 | 300 | 2023-01-02|
| 3 | 101 | 700 | 2023-01-04|
| 4 | 103 | 400 | 2023-01-06|
| 5 | 104 | 600 | 2023-01-07|
**Employees Table**:
| EmployeeID | EmployeeName | Department |
|------------|--------------|------------|
| 101 | John Doe | Sales |
| 102 | Jane Smith | Sales |
| 103 | Bob Johnson | Support |
| 104 | Alice Brown | Sales |
Please sign-in to view the solution
Given the following database schema, write SQL queries to answer the specific questions.
Schema:
**Employees Table**:
| EmployeeID | EmployeeName | DepartmentID |
|------------|--------------|--------------|
| 1 | John Doe | 10 |
| 2 | Jane Smith | 20 |
| 3 | Bob Johnson | 10 |
| 4 | Alice Brown | 30 |
**Departments Table**:
| DepartmentID | DepartmentName |
|--------------|----------------|
| 10 | Sales |
| 20 | Marketing |
| 30 | Support |
**Sales Table**:
| SaleID | EmployeeID | SaleAmount | SaleDate |
|--------|------------|------------|-----------|
| 1 | 1 | 500 | 2023-01-01|
| 2 | 2 | 300 | 2023-01-02|
| 3 | 1 | 700 | 2023-01-04|
| 4 | 3 | 400 | 2023-01-06|
| 5 | 4 | 600 | 2023-01-07|
Specific SQL Queries:
- Query 1: Find the total sales amount for each department.
- Query 2: Identify the top-performing employee in terms of sales within each department.
- Query 3: List all employees along with their department names and total sales.
Please sign-in to view the solution
You mentioned your proficiency with SQL and data forecasting. Can you describe a past experience where you used SQL to analyze data and generate a forecast? What challenges did you face, and how did you address them?
Please sign-in to view the solution
What type of SQL joins do you know?
Please sign-in to view the solution
What is OLAP and what are its differences compared to other database types?
Please sign-in to view the solution
What is Big Data and what is Hadoop used for?
Please sign-in to view the solution
How will you build a patent system?
Please sign-in to view the solution
How many websites are on the internet? How would you find out the number?
Please sign-in to view the solution