SQL Assignment 2
SQL Assignment 2
the database?
data integrity in the table. Normalization also helps to organize the data in the
database. It is a multi-step process that sets the data into tabular form and removes
normal forms, whereas normal forms are specific rules that define each level
of normalization.
There are several types of normal forms that define the level of
requires that each column in a table should contain atomic values, meaning
Second Normal Form (2NF): This level of normalization requires that a table
should be in 1NF and that all non-key attributes are fully dependent on the
primary key. In other words, there should not be any partial dependencies.
Third Normal Form (3NF): This level of normalization requires that a table
should be in 2NF and that all non-key attributes are independent of each
Fourth Normal Form (4NF): This form requires that a table should be in BCNF
and that it should not have any multi-valued dependencies. In other words, a
Fifth Normal Form (5NF): This form is also known as Project-Join Normal
Form (PJNF) and requires that a table should be in 4NF and that it should not
have any join dependencies. In other words, a table should not contain any
breaking down larger tables into smaller ones and creating relationships
stored in only one place, thereby minimizing data duplication. For example, in
table from the orders they have placed. This avoids storing the same
redundancy.
any changes made to one copy may not be reflected in the other copies,
6. What are the primary key and foreign keys? Give an example
In a relational database, a primary key is a unique identifier for
each row in a table. A foreign key, on the other hand, is a column or set of
Here's an example to illustrate the concept of primary keys and foreign keys:
Let's consider two tables: "Customers" and "Orders". The "Customers" table
column could be set as the primary key since it uniquely identifies each
customer.
The "Orders" table, on the other hand, might have columns such as "OrderID",
indicating that each order in the "Orders" table is associated with a specific
"Customers" table, all associated orders can also be deleted from the
Key Attributes: These are attributes that uniquely identify each row in a table.
In other words, they are the columns that make up the primary key of a table.
Non-Key Attributes: These are attributes that are not part of the primary key
but still provide important information about the entities in the table. For
table, where the value of one attribute determines the value of another
any subset of the key attributes. For example, in a table of orders, the price of
8. What is denormalization ?
are:-
two approaches serve different purposes and should be used selectively based on
Advantages of Normalization:
1. Reduced Data Redundancy: Normalization eliminates data redundancy by
breaking larger tables into smaller ones, which helps to improve data consistency
2. Improved Data Integrity: Normalization helps to ensure that each piece of data is
stored in only one place, which minimizes duplication and potential inconsistencies,
Advantages of Denormalization:
performance by reducing the number of joins and queries needed to retrieve data.
2. Simplified Data Model: Denormalization can simplify the data model, making it