By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
By the end of this topic, students will be able to:
An Entity-Relationship (ER) diagram is a visual representation of a database schema, showing the relationships between entities (tables) and their attributes (columns). Entities are represented as rectangles, and relationships are shown as lines connecting the entities. ER diagrams help to identify data redundancy and ensure data consistency.
For example, consider a database for a university's student records. The ER diagram might include entities for Students, Courses, and Grades, with relationships between them.
SQL (Structured Query Language) is a programming language used to manage and manipulate data in relational databases. Advanced SQL queries involve using subqueries, joins, and aggregations to retrieve and manipulate data.
Normalization is the process of organizing data in a database to minimize data redundancy and improve data integrity. There are several normalization rules, including:
Database security involves protecting sensitive data from unauthorized access, modification, or destruction. Common security measures include:
Suppose we want to design an ER diagram for a database that stores information about books and their authors. The entities might include:
The ER diagram might look like this:
Suppose we want to retrieve the average salary of employees who work in the sales department. We might use the following SQL query:
SELECT AVG(salary) FROM employees WHERE department = 'Sales';
This query uses the AVG aggregation function to calculate the average salary, and the WHERE clause to filter the results to only include employees who work in the sales department.
Suppose we have a table called orders that stores information about customer orders, including the customer ID, order date, and product ID. However, the table also includes the customer name and address, which are not necessary for the order data.
orders
To normalize the table, we might split it into two tables: orders and customers. The orders table would include the order ID, customer ID, order date, and product ID, while the customers table would include the customer ID, name, and address.
customers
What is the purpose of an Entity-Relationship (ER) diagram?
A) To retrieve data from a database B) To design a database schema C) To perform a database query D) To encrypt data
Correct answer: B) To design a database schema
Why the distractors fail:
What is the purpose of a subquery in a SQL query?
A) To retrieve data from a single table B) To combine data from multiple tables C) To perform a calculation on data D) To filter data based on a condition
Correct answer: D) To filter data based on a condition
What is the first normalization rule?
A) Each table cell must contain a single value B) Each non-key attribute must depend on the entire primary key C) Each table must have a primary key D) Each table must have a foreign key
Correct answer: A) Each table cell must contain a single value
What is the purpose of access control in database security?
A) To encrypt data B) To backup data C) To restrict access to sensitive data based on user roles and permissions D) To perform a database query
Correct answer: C) To restrict access to sensitive data based on user roles and permissions
What is the purpose of a relationship between entities in an ER diagram?
A) To show the attributes of an entity B) To show the relationships between entities C) To show the primary key of an entity D) To show the foreign key of an entity
Correct answer: B) To show the relationships between entities
Describe the purpose of an Entity-Relationship (ER) diagram in database design. (10 marks)
Explain the difference between a subquery and a join in a SQL query. (10 marks)
Describe the first normalization rule and provide an example of how it is applied. (10 marks)
Explain the purpose of access control in database security. (10 marks)
Describe the purpose of a relationship between entities in an ER diagram. (10 marks)
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.