Database Design and Normalisation Code Challenges & Tips topic image left

Database Design and Normalisation Code Challenges & Tips

  • 10 Topics
Database Design and Normalisation Code Challenges & Tips topic image right



1. Write a SQL query to create a table named `Employees` that includes the following columns: `EmployeeID`, `FirstName`, `LastName`, `DepartmentID`, `HireDate`, and `Salary`. Ensure that `EmployeeID` is the primary key.

2. Normalize the following table to 3rd Normal Form (3NF): ``` Orders(OrderID, CustomerName, ProductID, ProductName, Quantity) ```

3. Write a SQL query to retrieve the total number of employees in each department from the `Employees` table, grouped by `DepartmentID`.

4. Create a SQL query to generate a list of customers who have placed more than 5 orders from the `Orders` table. Assume the table has columns `OrderID`, `CustomerID`, and `OrderDate`.

5. Given the following table structure: ``` Books(BookID, Title, AuthorID, AuthorName, PublisherID, PublisherName) ``` Normalize this to 2nd Normal Form (2NF) and provide the new table structures.

6. Write a SQL query that updates the `Salary` of all employees in the `Sales` department by 10%.

7. Create an SQL statement to join the `Products` table and the `Categories` table to find the total count of products in each category. The `Products` table has columns `ProductID`, `ProductName`, and `CategoryID`, while the `Categories` table has `CategoryID` and `CategoryName`.

8. Write a SQL command to delete all records from the `Orders` table where the `OrderDate` is older than one year from the current date.

9. Create a SQL view called `EmployeeSalaryView` that contains employee names and their corresponding salaries from the `Employees` table.

10. Design a table called `StudentCourses` that captures which students are enrolled in which courses. Assume a many-to-many relationship between `Students` and `Courses`.



Reveal all the approved answers to the questions above and explore all the types of Database Design and Normalisation questions and answers.

Explore Now