0% found this document useful (0 votes)
8 views29 pages

Database Management System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views29 pages

Database Management System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Overview

Database is a collection of related data and data is a collection of facts and figures that can be
processed to produce information.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
A database management system stores data in such a way that it becomes easier to
retrieve, manipulate, and produce information.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>

Database Management System Page 1


Characteristics
08 August 2024 22:51

• Real-world entity − A modern DBMS is more realistic and uses real-world


entities to design its architecture. It uses the behavior and attributes too.
For example, a school database may use students as an entity and their
age as an attribute.
• Relation-based tables − DBMS allows entities and relations among them to
form tables. A user can understand the architecture of a database just by
looking at the table names.
• Isolation of data and application − A database system is entirely different
than its data. A database is an active entity, whereas data is said to be
passive, on which the database works and organizes. DBMS also stores
metadata, which is data about data, to ease its own process.
• Less redundancy − DBMS follows the rules of normalization, which splits a
relation when any of its attributes is having redundancy in values.
Normalization is a mathematically rich and scientific process that reduces
data redundancy.
• Consistency − Consistency is a state where every relation in a database
remains consistent. There exist methods and techniques, which can
detect attempt of leaving database in inconsistent state. A DBMS can
provide greater consistency as compared to earlier forms of data storing
applications like file-processing systems.
• Query Language − DBMS is equipped with query language, which makes it
more efficient to retrieve and manipulate data. A user can apply as many
and as different filtering options as required to retrieve a set of data.
Traditionally it was not possible where file-processing system was used.
• ACID Properties − DBMS follows the concepts
of Atomicity, Consistency, Isolation, and Durability (normally shortened as
ACID). These concepts are applied on transactions, which manipulate data
in a database. ACID properties help the database stay healthy in multi-
transactional environments and in case of failure.
• Multiuser and Concurrent Access − DBMS supports multi-user environment
and allows them to access and manipulate data in parallel. Though there
are restrictions on transactions when users attempt to handle the same
data item, but users are always unaware of them.
• Multiple views − DBMS offers multiple views for different users. A user
who is in the Sales department will have a different view of database than
a person working in the Production department. This feature enables the
users to have a concentrate view of the database according to their
requirements.
• Security − Features like multiple views offer security to some extent
where users are unable to access data of other users and departments.
DBMS offers methods to impose constraints while entering data into the
database and retrieving the same at a later stage. DBMS offers many
different levels of security features, which enables multiple users to have
different views with different features. For example, a user in the Sales
department cannot see the data that belongs to the Purchase department.
Additionally, it can also be managed how much data of the Sales
department should be displayed to the user. Since a DBMS is not saved
on the disk as traditional file systems, it is very hard for miscreants to

Database Management System Page 2


on the disk as traditional file systems, it is very hard for miscreants to
break the code.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>

Database Management System Page 3


Users
08 August 2024 22:51

• Administrators − Administrators maintain the DBMS and are


responsible for administrating the database. They are responsible to
look after its usage and by whom it should be used. They create
access profiles for users and apply limitations to maintain isolation
and force security. Administrators also look after DBMS resources like
system license, required tools, and other software and hardware
related maintenance.
• Designers − Designers are the group of people who actually work on
the designing part of the database. They keep a close watch on what
data should be kept and in what format. They identify and design the
whole set of entities, relations, constraints, and views.
• End Users − End users are those who actually reap the benefits of
having a DBMS. End users can range from simple viewers who pay
attention to the logs or market rates to sophisticated users such as
business analysts.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>

Database Management System Page 4


Architecture
08 August 2024 22:52

In 1-tier architecture, the DBMS is the only entity where the user directly sits on the DBMS and uses
it. Any changes done here will directly be done on the DBMS itself. It does not provide handy tools
for end-users. Database designers and programmers normally prefer to use single-tier architecture.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>
If the architecture of DBMS is 2-tier, then it must have an application through which the DBMS can
be accessed. Programmers use 2-tier architecture where they access the DBMS by means of an
application. Here the application tier is entirely independent of the database in terms of operation,
design, and programming.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>

Database Management System Page 5


3-tier Architecture
08 August 2024 22:52

3-tier Architecture
A 3-tier architecture separates its tiers from each other based on the
complexity of the users and how they use the data present in the
database. It is the most widely used architecture to design a DBMS.

• Database (Data) Tier − At this tier, the database resides along with its
query processing languages. We also have the relations that define
the data and their constraints at this level.
• Application (Middle) Tier − At this tier reside the application server and
the programs that access the database. For a user, this application
tier presents an abstracted view of the database. End-users are
unaware of any existence of the database beyond the application. At
the other end, the database tier is not aware of any other user
beyond the application tier. Hence, the application layer sits in the
middle and acts as a mediator between the end-user and the
database.
• User (Presentation) Tier − End-users operate on this tier and they
know nothing about any existence of the database beyond this layer.
At this layer, multiple views of the database can be provided by the
application. All views are generated by applications that reside in the
application tier.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>

Database Management System Page 6


Data Models
08 August 2024 22:53

Data models define how the logical structure of a database is modeled. Data Models are
fundamental entities to introduce abstraction in a DBMS. Data models define how data is connected
to each other and how they are processed and stored inside the system.

From <https://www.tutorialspoint.com/dbms/dbms_data_models.htm>

Entity-Relationship Model
Entity-Relationship (ER) Model is based on the notion of real-world
entities and relationships among them. While formulating real-world
scenario into the database model, the ER Model creates entity set,
relationship set, general attributes and constraints.
ER Model is best used for the conceptual design of a database.
ER Model is based on −
• Entities and their attributes.
• Relationships among entities.
These concepts are explained below.

• Entity − An entity in an ER Model is a real-world entity having


properties called attributes. Every attribute is defined by its set of
values called domain. For example, in a school database, a student is
considered as an entity. Student has various attributes like name,
age, class, etc.
• Relationship − The logical association among entities is
called relationship. Relationships are mapped with entities in various
ways. Mapping cardinalities define the number of association between
two entities.
Mapping cardinalities −
○ one to one
○ one to many
○ many to one
○ many to many

From <https://www.tutorialspoint.com/dbms/dbms_data_models.htm>

Relational Model
The most popular data model in DBMS is the Relational Model. It is more
scientific a model than others. This model is based on first-order predicate
logic and defines a table as an n-ary relation.

Database Management System Page 7


The main highlights of this model are −
• Data is stored in tables called relations.
• Relations can be normalized.
• In normalized relations, values saved are atomic values.
• Each row in a relation contains a unique value.
• Each column in a relation contains values from a same domain.

From <https://www.tutorialspoint.com/dbms/dbms_data_models.htm>

Database Management System Page 8


Entity-Set and Keys
08 August 2024 22:56

• Super Key − A set of attributes (one or more) that collectively identifies an


entity in an entity set.
• Candidate Key − A minimal super key is called a candidate key. An entity set
may have more than one candidate key.
• Primary Key − A primary key is one of the candidate keys chosen by the
database designer to uniquely identify the entity set.

From <https://www.tutorialspoint.com/dbms/er_model_basic_concepts.htm>

Database Management System Page 9


Database Schema
08 August 2024 22:54

A database schema is the skeleton structure that represents the logical view of the entire database.
It defines how the data is organized and how the relations among them are associated. It formulates
all the constraints that are to be applied on the data.

From <https://www.tutorialspoint.com/dbms/dbms_data_schemas.htm>
• Physical Database Schema − This schema pertains to the actual storage of
data and its form of storage like files, indices, etc. It defines how the data
will be stored in a secondary storage.
• Logical Database Schema − This schema defines all the logical constraints
that need to be applied on the data stored. It defines tables, views, and
integrity constraints.

From <https://www.tutorialspoint.com/dbms/dbms_data_schemas.htm>

Database Management System Page 10


Data Independence
08 August 2024 22:55

Logical Data Independence


Logical data is data about database, that is, it stores information about
how data is managed inside.

From <https://www.tutorialspoint.com/dbms/dbms_data_independence.htm>

Physical Data Independence


All the schemas are logical, and the actual data is stored in bit format on
the disk. Physical data independence is the power to change the physical
data without impacting the schema or logical data.

From <https://www.tutorialspoint.com/dbms/dbms_data_independence.htm>

Database Management System Page 11


ER Diagram Representation
08 August 2024 22:57

Entity
Entities are represented by means of rectangles. Rectangles are named
with the entity set they represent.

Attributes
Attributes are the properties of entities. Attributes are represented by
means of ellipses. Every ellipse represents one attribute and is directly
connected to its entity (rectangle).

If the attributes are composite, they are further divided in a tree like
structure. Every node is then connected to its attribute. That is,
composite attributes are represented by ellipses that are connected with
an ellipse.

Multivalued attributes are depicted by double ellipse.

Database Management System Page 12


Derived attributes are depicted by dashed ellipse.

Explore our latest online courses and learn new skills at your own pace.
Enroll and become a certified expert to boost your career.

Relationship
Relationships are represented by diamond-shaped box. Name of the
relationship is written inside the diamond-box. All the entities (rectangles)
participating in a relationship, are connected to it by a line.
Binary Relationship and Cardinality
A relationship where two entities are participating is called a binary
relationship. Cardinality is the number of instance of an entity from a
relation that can be associated with the relation.
• One-to-one − When only one instance of an entity is associated with
the relationship, it is marked as '1:1'. The following image reflects
that only one instance of each entity should be associated with the
relationship. It depicts one-to-one relationship.

Database Management System Page 13


• One-to-many − When more than one instance of an entity is
associated with a relationship, it is marked as '1:N'. The following
image reflects that only one instance of entity on the left and more
than one instance of an entity on the right can be associated with the
relationship. It depicts one-to-many relationship.

• Many-to-one − When more than one instance of entity is associated


with the relationship, it is marked as 'N:1'. The following image
reflects that more than one instance of an entity on the left and only
one instance of an entity on the right can be associated with the
relationship. It depicts many-to-one relationship.

• Many-to-many − The following image reflects that more than one


instance of an entity on the left and more than one instance of an
entity on the right can be associated with the relationship. It depicts
many-to-many relationship.

Participation Constraints
• Total Participation − Each entity is involved in the relationship. Total
participation is represented by double lines.
• Partial participation − Not all entities are involved in the relationship.
Partial participation is represented by single lines.

Database Management System Page 14


From <https://www.tutorialspoint.com/dbms/er_diagram_representation.htm>

Database Management System Page 15


Generalization Aggregation
08 August 2024 22:58

Generalization
As mentioned above, the process of generalizing entities, where the
generalized entities contain the properties of all the generalized entities,
is called generalization. In generalization, a number of entities are
brought together into one generalized entity based on their similar
characteristics. For example, pigeon, house sparrow, crow and dove can
all be generalized as Birds.

From <https://www.tutorialspoint.com/dbms/dbms_generalization_aggregation.htm>

Specialization
Specialization is the opposite of generalization. In specialization, a group
of entities is divided into sub-groups based on their characteristics. Take
a group ‘Person’ for example. A person has name, date of birth, gender,
etc. These properties are common in all persons, human beings. But in a
company, persons can be identified as employee, employer, customer, or
vendor, based on what role they play in the company.

Similarly, in a school database, persons can be specialized as teacher,


student, or a staff, based on what role they play in school as entities.

From <https://www.tutorialspoint.com/dbms/dbms_generalization_aggregation.htm>

Inheritance
We use all the above features of ER-Model in order to create classes of
objects in object-oriented programming. The details of entities are
generally hidden from the user; this process known as abstraction.
Inheritance is an important feature of Generalization and Specialization. It
allows lower-level entities to inherit the attributes of higher-level entities.

Database Management System Page 16


For example, the attributes of a Person class such as name, age, and
gender can be inherited by lower-level entities such as Student or
Teacher.

From <https://www.tutorialspoint.com/dbms/dbms_generalization_aggregation.htm>

Database Management System Page 17


Relation Data Model
08 August 2024 23:00

Concepts
Tables − In relational data model, relations are saved in the format of
Tables. This format stores the relation among entities. A table has rows
and columns, where rows represents records and columns represent the
attributes.
Tuple − A single row of a table, which contains a single record for that
relation is called a tuple.
Relation instance − A finite set of tuples in the relational database system
represents relation instance. Relation instances do not have duplicate
tuples.
Relation schema − A relation schema describes the relation name (table
name), attributes, and their names.
Relation key − Each row has one or more attributes, known as relation
key, which can identify the row in the relation (table) uniquely.
Attribute domain − Every attribute has some pre-defined value scope,
known as attribute domain.

From <https://www.tutorialspoint.com/dbms/relational_data_model.htm>

Database Management System Page 18


SQL
08 August 2024 23:08

Types of SQL Commands


There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.

1. Data Definition Language (DDL)


• DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
• All the command of DDL are auto-committed that means it permanently save all
the changes in the database.
Here are some commands that come under DDL:
• CREATE
• ALTER
• DROP
• TRUNCATE
a. CREATE It is used to create a new table in the database.
Syntax:
1. CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);
Example:
1. CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DO
B DATE);
b. DROP: It is used to delete both the structure and record stored in the table.
Syntax
1. DROP TABLE table_name;
Example
1. DROP TABLE EMPLOYEE;
c. ALTER: It is used to alter the structure of the database. This change could be
either to modify the characteristics of an existing attribute or probably to add a new
attribute.
Syntax:
To add a new column in the table
1. ALTER TABLE table_name ADD column_name COLUMN-definition;
To modify existing column in the table:
1. ALTER TABLE table_name MODIFY(column_definitions....);
EXAMPLE
1. ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));

Database Management System Page 19


1. ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
2. ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));
d. TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax:
1. TRUNCATE TABLE table_name;
Example:
1. TRUNCATE TABLE EMPLOYEE;
2. Data Manipulation Language
• DML commands are used to modify the database. It is responsible for all form
of changes in the database.
• The command of DML is not auto-committed that means it can't permanently
save all the changes in the database. They can be rollback.
Here are some commands that come under DML:
• INSERT
• UPDATE
• DELETE
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into the
row of a table.
Syntax:
1. INSERT INTO TABLE_NAME
2. (col1, col2, col3,.... col N)
3. VALUES (value1, value2, value3, .... valueN);
Or
1. INSERT INTO TABLE_NAME
2. VALUES (value1, value2, value3, .... valueN);
For example:
1. INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo", "DBMS");
b. UPDATE: This command is used to update or modify the value of a column in the
table.
Syntax:
1. UPDATE table_name SET [column_name1
= value1,...column_nameN = valueN] [WHERE CONDITION]
For example:
1. UPDATE students
2. SET User_Name = 'Sonoo'
3. WHERE Student_Id = '3'
c. DELETE: It is used to remove one or more row from a table.
Syntax:
1. DELETE FROM table_name [WHERE condition];
For example:
1. DELETE FROM javatpoint
2. WHERE Author="Sonoo";
3. Data Control Language
DCL commands are used to grant and take back authority from any database user.
Here are some commands that come under DCL:
• Grant
• Revoke
a. Grant: It is used to give user access privileges to a database.
Example
1. GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;

Database Management System Page 20


1. GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
b. Revoke: It is used to take back permissions from the user.
Example
1. REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
4. Transaction Control Language
TCL commands can only use with DML commands like INSERT, DELETE and
UPDATE only.
These operations are automatically committed in the database that's why they
cannot be used while creating tables or dropping them.
ADVERTISEMENT
Here are some commands that come under TCL:
• COMMIT
• ROLLBACK
• SAVEPOINT
a. Commit: Commit command is used to save all the transactions to the database.
Syntax:
1. COMMIT;
Example:
1. DELETE FROM CUSTOMERS
2. WHERE AGE = 25;
3. COMMIT;
b. Rollback: Rollback command is used to undo transactions that have not already
been saved to the database.
Syntax:
1. ROLLBACK;
Example:
1. DELETE FROM CUSTOMERS
2. WHERE AGE = 25;
3. ROLLBACK;
c. SAVEPOINT: It is used to roll the transaction back to a certain point without rolling
back the entire transaction.
Syntax:
1. SAVEPOINT SAVEPOINT_NAME;
5. Data Query Language
DQL is used to fetch the data from the database.
It uses only one command:
• SELECT
a. SELECT: This is the same as the projection operation of relational algebra. It is
used to select the attribute based on the condition described by WHERE clause.
Syntax:
1. SELECT expressions
2. FROM TABLES
3. WHERE conditions;
For example:
1. SELECT emp_name
2. FROM employee
3. WHERE age > 20;

From <https://www.javatpoint.com/dbms-sql-command>

Database Management System Page 21


Relational Algebra
08 August 2024 23:00

Relational Algebra
Relational algebra is a procedural query language. It gives a step by step process to
obtain the result of the query. It uses operators to perform queries.
Types of Relational operation

1. Select Operation:
ADVERTISEMENT

• The select operation selects tuples that satisfy a given predicate.


• It is denoted by sigma (σ).
1. Notation: σ p(r)
Where:
σ is used for selection prediction
r is used for relation
p is used as a propositional logic formula which may use connectors like: AND OR
and NOT. These relational can use as relational operators like =, ≠, ≥, <, >, ≤.
For example: LOAN Relation
BRANCH_NAME LOAN_NO AMOUNT
Downtown L-17 1000
Redwood L-23 2000
Perryride L-15 1500
Downtown L-14 1500
Mianus L-13 500
Roundhill L-11 900
Perryride L-16 1300
Input:
1. σ BRANCH_NAME="perryride" (LOAN)
Output:
BRANCH_NAME LOAN_NO AMOUNT
Perryride L-15 1500
Perryride L-16 1300
2. Project Operation:
• This operation shows the list of those attributes that we wish to appear in the
result. Rest of the attributes are eliminated from the table.
It is denoted by ∏.
Database Management System Page 22
• It is denoted by ∏.
1. Notation: ∏ A1, A2, An (r)
Where
A1, A2, A3 is used as an attribute name of relation r.
Example: CUSTOMER RELATION
NAME STREET CITY
Jones Main Harrison
Smith North Rye
Hays Main Harrison
Curry North Rye
Johnson Alma Brooklyn
Brooks Senator Brooklyn
Input:
1. ∏ NAME, CITY (CUSTOMER)
Output:
NAME CITY
Jones Harrison
Smith Rye
Hays Harrison
Curry Rye
Johnson Brooklyn
Brooks Brooklyn
3. Union Operation:
• Suppose there are two tuples R and S. The union operation contains all the
tuples that are either in R or S or both in R & S.
• It eliminates the duplicate tuples. It is denoted by ∪.
1. Notation: R ∪ S
A union operation must hold the following condition:
• R and S must have the attribute of the same number.
• Duplicate tuples are eliminated automatically.
Example:
DEPOSITOR RELATION
CUSTOMER_NAME ACCOUNT_NO
Johnson A-101
Smith A-121
Mayes A-321
Turner A-176
Johnson A-273
Jones A-472
Lindsay A-284
BORROW RELATION
CUSTOMER_NAME LOAN_NO
Jones L-17
Smith L-23

Database Management System Page 23


Smith L-23
Hayes L-15
Jackson L-14
Curry L-93
Smith L-11
Williams L-17
Input:
1. ∏ CUSTOMER_NAME (BORROW) ∪ ∏ CUSTOMER_NAME (DEPOSITOR)
Output:
CUSTOMER_NAME
Johnson
Smith
Hayes
Turner
Jones
Lindsay
Jackson
Curry
Williams
Mayes
4. Set Intersection:
• Suppose there are two tuples R and S. The set intersection operation contains
all tuples that are in both R & S.
• It is denoted by intersection ∩.
1. Notation: R ∩ S
Example: Using the above DEPOSITOR table and BORROW table
Input:
1. ∏ CUSTOMER_NAME (BORROW) ∩ ∏ CUSTOMER_NAME (DEPOSITOR)
Output:
CUSTOMER_NAME
Smith
Jones
5. Set Difference:
• Suppose there are two tuples R and S. The set intersection operation contains
all tuples that are in R but not in S.
• It is denoted by intersection minus (-).
1. Notation: R - S
Example: Using the above DEPOSITOR table and BORROW table
Input:
1. ∏ CUSTOMER_NAME (BORROW) - ∏ CUSTOMER_NAME (DEPOSITOR)
Output:
CUSTOMER_NAME
Jackson
Hayes

Database Management System Page 24


Willians
Curry
6. Cartesian product
• The Cartesian product is used to combine each row in one table with each row
in the other table. It is also known as a cross product.
• It is denoted by X.
1. Notation: E X D
Example:
EMPLOYEE
EMP_ID EMP_NAME EMP_DEPT
1 Smith A
2 Harry C
3 John B
DEPARTMENT
DEPT_NO DEPT_NAME
A Marketing
B Sales
C Legal
Input:
1. EMPLOYEE X DEPARTMENT
Output:
EMP_ID EMP_NAME EMP_DEPT DEPT_NO DEPT_NAME
1 Smith A A Marketing
1 Smith A B Sales
1 Smith A C Legal
2 Harry C A Marketing
2 Harry C B Sales
2 Harry C C Legal
3 John B A Marketing
3 John B B Sales
3 John B C Legal
7. Rename Operation:
The rename operation is used to rename the output relation. It is denoted by rho (ρ).
Example: We can use the rename operator to rename STUDENT relation to
STUDENT1.
1. ρ(STUDENT1, STUDENT)

From <https://www.javatpoint.com/dbms-relational-algebra>

Database Management System Page 25


Normalization
08 August 2024 23:01

A large database defined as a single relation may result in data duplication. This
repetition of data may result in:
• Making relations very large.
• It isn't easy to maintain and update data as it would involve searching many
records in relation.
• Wastage and poor utilization of disk space and resources.
• The likelihood of errors and inconsistencies increases.
So to handle these problems, we should analyze and decompose the relations with
redundant data into smaller, simpler, and well-structured relations that are satisfy
desirable properties. Normalization is a process of decomposing the relations into
relations with fewer attributes.
What is Normalization?
• Normalization is the process of organizing the data in the database.
• Normalization is used to minimize the redundancy from a relation or set of
relations. It is also used to eliminate undesirable characteristics like Insertion,
Update, and Deletion Anomalies.
• Normalization divides the larger table into smaller and links them using
relationships.
• The normal form is used to reduce redundancy from the database table.
Why do we need Normalization?
The main reason for normalizing the relations is removing these anomalies. Failure
to eliminate anomalies leads to data redundancy and can cause data integrity and
other problems as the database grows. Normalization consists of a series of
guidelines that helps to guide you in creating a good database structure.
Data modification anomalies can be categorized into three types:
• Insertion Anomaly: Insertion Anomaly refers to when one cannot insert a new
tuple into a relationship due to lack of data.
• Deletion Anomaly: The delete anomaly refers to the situation where the
deletion of data results in the unintended loss of some other important data.
• Updatation Anomaly: The update anomaly is when an update of a single data
value requires multiple rows of data to be updated.
Types of Normal Forms:
Normalization works through a series of stages called Normal forms. The normal
forms apply to individual relations. The relation is said to be in particular normal form
if it satisfies constraints.
Following are the various types of Normal forms:

Database Management System Page 26


Normal Description
Form
1NF A relation is in 1NF if it contains an atomic value.
2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully
functional dependent on the primary key.
3NF A relation will be in 3NF if it is in 2NF and no transition dependency
exists.
BCNF A stronger definition of 3NF is known as Boyce Codd's normal form.
4NF A relation will be in 4NF if it is in Boyce Codd's normal form and has no
multi-valued dependency.
5NF A relation is in 5NF. If it is in 4NF and does not contain any join
dependency, joining should be lossless.
Advantages of Normalization
• Normalization helps to minimize data redundancy.
• Greater overall database organization.
• Data consistency within the database.
• Much more flexible database design.
• Enforces the concept of relational integrity.
Disadvantages of Normalization
• You cannot start building the database before knowing what the user needs.
• The performance degrades when normalizing the relations to higher normal
forms, i.e., 4NF, 5NF.
• It is very time-consuming and difficult to normalize relations of a higher degree.
• Careless decomposition may lead to a bad database design, leading to serious
problems.

From <https://www.javatpoint.com/dbms-normalization>

Database Management System Page 27


SQL JOIN
08 August 2024 23:03

SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based on a
related column between them.
Let's look at a selection from the "Orders" table:
OrderID CustomerID OrderDate
10308 2 1996-09-18
10309 37 1996-09-19
10310 77 1996-09-20
Then, look at a selection from the "Customers" table:
CustomerID CustomerName ContactName Country
1 Alfreds Futterkiste Maria Anders Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Mexico
3 Antonio Moreno Taquería Antonio Moreno Mexico
Notice that the "CustomerID" column in the "Orders" table refers to the
"CustomerID" in the "Customers" table. The relationship between the two
tables above is the "CustomerID" column.
Then, we can create the following SQL statement (that contains an INNER
JOIN), that selects records that have matching values in both tables:

ExampleGet your own SQL Server


SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate

FROM Orders

INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

Try it Yourself »

and it will produce something like this:


OrderID CustomerName OrderDate
10308 Ana Trujillo Emparedados y helados 9/18/1996
10365 Antonio Moreno Taquería 11/27/1996
10383 Around the Horn 12/16/1996
10355 Around the Horn 11/15/1996
10278 Berglunds snabbköp 8/12/1996

Different Types of SQL JOINs


Here are the different types of the JOINs in SQL:
• (INNER) JOIN: Returns records that have matching values in both tables

Database Management System Page 28


• (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

From <https://www.w3schools.com/sql/sql_join.asp>

Database Management System Page 29

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy