0% found this document useful (0 votes)
49 views74 pages

FSD Unit V

Uploaded by

decmonster24
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)
49 views74 pages

FSD Unit V

Uploaded by

decmonster24
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/ 74

Relational Schemas UNIT-V

Database Schema
A database schema is a structure that represents the logical storage of the data
in a database. It represents the organization of data and provides
information about the relationships between the tables in a given database.
What is Database?
A database is a place to store information. It can store the simplest data,
such as a list of people as well as the most complex data. The database
stores the information in a well-structured format.
What is Database Schema?
o A database schema is the logical representation of a database, which
shows how the data is stored logically in the entire database. It
contains list of attributes and instruction that informs the database
engine that how the data is organized and how the elements are
related to each other.
o A database schema contains schema objects that may include tables,
fields, packages, views, relationships, primary key, foreign key,
o In actual, the data is physically stored in files that may be in
unstructured form, but to retrieve it and use it, we need to put it in a
structured form. To do this, a database schema is used. It provides
knowledge about how the data is organized in a database and how it
is associated with other data.
o The schema does not physically contain the data itself; instead, it gives
information about the shape of data and how it can be related to other
tables or models.
o A database schema object includes the following:
o Consistent formatting for all data entries.
o Database objects and unique keys for all data entries.
o Tables with multiple columns, and each column contains its
name and datatype.
o The complexity & the size of the schema vary as per the size of the
project. It helps developers to easily manage and structure the
database before coding it.
o The given diagram is an example of a database schema. It contains
three tables, their data types. This also represents the relationships
between the tables and primary keys as well as foreign keys.

Page | 1
Relational Schemas UNIT-V

Types of Database Schema


The database schema is divided into three types, which are:
1. Logical Schema
2. Physical Schema
3. View Schema

Page | 2
Relational Schemas UNIT-V

1. Physical Database Schema


A physical database schema specifies how the data is stored physically on a
storage system or disk storage in the form of Files and Indices. Designing a
database at the physical level is called a physical schema.
2. Logical Database Schema
The Logical database schema specifies all the logical constraints that need
to be applied to the stored data. It defines the views, integrity constraints,
and table. Here the term integrity constraints define the set of rules that are
used by DBMS (Database Management System) to maintain the quality for
insertion & update the data. The logical schema represents how the data is
stored in the form of tables and how the attributes of a table are linked
together.
At this level, programmers and administrators work, and the
implementation of the data structure is hidden at this level.
Various tools are used to create a logical database schema, and these tools
demonstrate the relationships between the components of your data; this
process is called ER modelling.
The ER modelling stands for entity-relationship modelling, which specifies
the relationships between different entities.
We can understand it with an example of a basic commerce application.
Below is the schema diagram, the simple ER model representing the logical
flow of transaction in a commerce application.

Page | 3
Relational Schemas UNIT-V

In the given example, the Ids are given in each circle, and these Ids are
primary key & foreign keys.
The primary key is used to uniquely identify the entry in a document or
record. The Ids of the upper three circles are the primary keys.
The Foreign key is used as the primary key for other tables. The FK represent
the foreign key in the diagram. It relates one table to another table.
3. View Schema
The view level design of a database is known as view schema. This schema
generally describes the end-user interaction with the database systems.
Difference between the Physical and Logical Database
Schema
Physical database schema Logical Database schema

It does not include the attributes. It includes the attributes.

It contains both primary & secondary It also contains both primary &
Keys. secondary keys.

It contains the table name. It contains the names of the tables.

It contains the column names and their It does not contain any column name
data types. or datatype.

Creating Schema
To create a schema, "CREATE SCHEMA" Statements is used in each type of
database. But each DBMS has a different meaning for this. Below we are
explaining creating schema in different database systems:
1. MySQL
In MySQL, the "CREATE SCHEMA" statement creates the database. It is
because, in MySQL, the CREATE SCHEMA statement is similar to CREATE
DATABASE statement, and schema is a synonym for the database.
2. Oracle Database
In Oracle Database, each schema is already present with each database
user. Hence CREATE SCHEMA does not actually create a schema; rather, it
helps to show the schema with tables and views and allows to access those
objects without requiring multiple SQL statements for multiple transactions.
The "CREATE USER" statement is used to create a schema in Oracle.

Page | 4
Relational Schemas UNIT-V

3. SQL Server
In the SQL server, the "CREATE SCHEMA" statement creates a new schema
with the name provided by the user.
Database Schema Designs
A schema design is the first step in building a foundation in data
management. Ineffective schema designs are difficult to manage and
consume more memory and other resources. It logically depends on the
business requirements. It is required to choose the correct database
schema design to make ease in the project lifecycle. The list of some
popular database schema designs is given below:
o Flat Model
o Hierarchical Model
o Network Model
o Relational Model
o Star Schema
o Snowflake Schema
Flat Model
A flat model schema is a type of 2-D array in which each column contains
the same type of data, and elements within a row are related to each other.
It can be understood as a single spreadsheet or a database table with no
relations. This schema design is most suitable for small applications that
don't contain complex data.
Hierarchical Model
The Hierarchical model design contains a tree-like structure. The tree
structure contains the root node of data and its child nodes. Between each
child node and parent node, there is a one-to-many relationship. Such type
of database schemas is presented by XML or JSON files, as these files can
contain the entities with their sub-entities.
The hierarchical schema models are best suitable for storing the nested
data, such as representing Hominoid classification.
Network Model
The network model design is similar to hierarchical design as it represents a
series of nodes and vertices. The main difference between the network
model and the hierarchical model is that the network model allows a many-
to-many relationship. In contrast, the hierarchical model only allows a one-
to-many relationship.

Page | 5
Relational Schemas UNIT-V

The network model design is best suitable for applications that require
spatial calculations. It is also great for representing workflows and mainly
for cases with multiple paths to the same result.
Relational Model
The relational models are used for the relational database, which stores
data as relations of the table. There are relational operators used to operate
on data to manipulate and calculate different values from it.
Star Schema
The star schema is a different way of schema design to organize the data. It
is best suitable for storing and analyzing a huge amount of data, and it
works on "Facts" and "Dimensions". Here the fact is the numerical data
point that runs business processes, and Dimension is a description of fact.
With Star Schema, we can structure the data of RDBMS.
Snowflake Schema
The snowflake schema is an adoption of a star schema. There is a main
"Fact" table in the star schema that contains the main data points and
reference to its dimension tables. But in snowflake, dimension tables can
have their own dimension tables.

Page | 6
Normalization UNIT-V

Normalization
A large database defined as a single relation may result in data duplication.
This repetition of data may result in:
o Making relations very large.
o It isn't easy to maintain and update data as it would involve searching
many records in relation.
o Wastage and poor utilization of disk space and resources.
o 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 satisfying desirable properties. Normalization is a process
of decomposing the relations into relations with fewer attributes.
What is Normalization?
o Normalization is the process of organizing the data in the database.
o 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.
o Normalization divides the larger table into smaller and links them
using relationships.
o 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:
o Insertion Anomaly: Insertion Anomaly refers to when one cannot
insert a new tuple into a relationship due to lack of data.
o Deletion Anomaly: The delete anomaly refers to the situation where
the deletion of data results in the unintended loss of some other
important data.

Page | 7
Normalization UNIT-V

o 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:

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.

Page | 8
Normalization UNIT-V

Advantages of Normalization
o Normalization helps to minimize data redundancy.
o Greater overall database organization.
o Data consistency within the database.
o Much more flexible database design.
o Enforces the concept of relational integrity.
Disadvantages of Normalization
o You cannot start building the database before knowing what the user
needs.
o The performance degrades when normalizing the relations to higher
normal forms, i.e., 4NF, 5NF.
o It is very time-consuming and difficult to normalize relations of a
higher degree.
o Careless decomposition may lead to a bad database design, leading
to serious problems.
First Normal Form (1NF)
o A relation will be 1NF if it contains an atomic value.
o It states that an attribute of a table cannot hold multiple values. It
must hold only single-valued attribute.
o First normal form disallows the multi-valued attribute, composite
attribute, and their combinations.
Example: Relation EMPLOYEE is not in 1NF because of multi-valued
attribute EMP_PHONE.
EMPLOYEE table:

EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385, UP
9064738238

20 Harry 8574783832 Bihar

12 Sam 7390372389, Punjab


8589830302

Page | 9
Normalization UNIT-V

The decomposition of the EMPLOYEE table into 1NF has been shown
below:

EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385 UP

14 John 9064738238 UP

20 Harry 8574783832 Bihar

12 Sam 7390372389 Punjab

12 Sam 8589830302 Punjab

Second Normal Form (2NF)


o In the 2NF, relational must be in 1NF.
o In the second normal form, all non-key attributes are fully functional
dependent on the primary key
Example: Let's assume, a school can store the data of teachers and the
subjects they teach. In a school, a teacher can teach more than one subject.
TEACHER table

TEACHER_ID SUBJECT TEACHER_AGE

25 Chemistry 30

25 Biology 30

47 English 35

83 Math 38

83 Computer 38
In the given table, non-prime attribute TEACHER_AGE is dependent on
TEACHER_ID which is a proper subset of a candidate key. That's why it
violates the rule for 2NF.

Page | 10
Normalization UNIT-V

To convert the given table into 2NF, we decompose it into two tables:
TEACHER_DETAIL table:

TEACHER_ID TEACHER_AGE

25 30

47 35

83 38
TEACHER_SUBJECT table:

TEACHER_ID SUBJECT

25 Chemistry

25 Biology

47 English

83 Math

83 Computer

Third Normal Form (3NF)


o A relation will be in 3NF if it is in 2NF and not contain any transitive
partial dependency.
o 3NF is used to reduce the data duplication. It is also used to achieve
the data integrity.
o If there is no transitive dependency for non-prime attributes, then the
relation must be in third normal form.
A relation is in third normal form if it holds atleast one of the following
conditions for every non-trivial function dependency X → Y.
1. X is a super key.
2. Y is a prime attribute, i.e., each element of Y is part of some candidate
key.

Page | 11
Normalization UNIT-V

Example:
EMPLOYEE_DETAIL table:

EMP_ID EMP_NAME EMP_ZIP EMP_STATE EMP_CITY

222 Harry 201010 UP Noida

333 Stephan 02228 US Boston

444 Lan 60007 US Chicago

555 Katharine 06389 UK Norwich

666 John 462007 MP Bhopal


Super key in the table above:
1. {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so
on
Candidate key: {EMP_ID}
Non-prime attributes: In the given table, all attributes except
EMP_ID are non-prime.
Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP
dependent on EMP_ID. The non-prime attributes (EMP_STATE,
EMP_CITY) transitively dependent on super key(EMP_ID). It violates
the rule of third normal form.
That's why we need to move the EMP_CITY and EMP_STATE to the
new <EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.
EMPLOYEE table:

EMP_ID EMP_NAME EMP_ZIP

222 Harry 201010

333 Stephan 02228

444 Lan 60007

555 Katharine 06389

Page | 12
Normalization UNIT-V

666 John 462007

EMPLOYEE_ZIP table:

EMP_ZIP EMP_STATE EMP_CITY

201010 UP Noida

02228 US Boston

60007 US Chicago

06389 UK Norwich

462007 MP Bhopal

Boyce Codd normal form (BCNF)


o BCNF is the advance version of 3NF. It is stricter than 3NF.
o A table is in BCNF if every functional dependency X → Y, X is the
super key of the table.
o For BCNF, the table should be in 3NF, and for every FD, LHS is super
key.
Example: Let's assume there is a company where employees work in more
than one department.
EMPLOYEE table:

EMP_ID EMP_COUNTRY EMP_DEPT DEPT_T EMP_DE


YPE PT_NO

264 India Designing D394 283

264 India Testing D394 300

364 UK Stores D283 232

364 UK Developing D283 549

In the above table Functional dependencies are as follows:


1. EMP_ID → EMP_COUNTRY

Page | 13
Normalization UNIT-V

2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}


Candidate key: {EMP-ID, EMP-DEPT}
The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are
keys.
To convert the given table into BCNF, we decompose it into three tables:
EMP_COUNTRY table:

EMP_ID EMP_COUNTRY

264 India

264 India
EMP_DEPT table:

EMP_DEPT DEPT_TYPE EMP_DEPT_NO

Designing D394 283

Testing D394 300

Stores D283 232

Developing D283 549


EMP_DEPT_MAPPING table:

EMP_ID EMP_DEPT

D394 283

D394 300

D283 232

D283 549
Functional dependencies:
1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:

Page | 14
Normalization UNIT-V

For the first table: EMP_ID


For the second table: EMP_DEPT
For the third table: {EMP_ID, EMP_DEPT}
Now, this is in BCNF because left side part of both the functional
dependencies is a key.
Fourth normal form (4NF)
o A relation will be in 4NF if it is in Boyce Codd normal form and has no
multi-valued dependency.
o For a dependency A → B, if for a single value of A, multiple values of
B exists, then the relation will be a multi-valued dependency.
Example
STUDENT

STU_ID COURSE HOBBY

21 Computer Dancing

21 Math Singing

34 Chemistry Dancing

74 Biology Cricket

59 Physics Hockey

The given STUDENT table is in 3NF, but the COURSE and HOBBY are two
independent entity. Hence, there is no relationship between COURSE and
HOBBY.
In the STUDENT relation, a student with STU_ID, 21 contains two
courses, Computer and Math and two hobbies, Dancing and Singing. So
there is a Multi-valued dependency on STU_ID, which leads to unnecessary
repetition of data.
So to make the above table into 4NF, we can decompose it into two tables:

Page | 15
Normalization UNIT-V

STUDENT_COURSE

STU_ID COURSE

21 Computer

21 Math

34 Chemistry

74 Biology

59 Physics

STUDENT_HOBBY

STU_ID HOBBY

21 Dancing

21 Singing

34 Dancing

74 Cricket

59 Hockey

Fifth normal form (5NF)


o A relation is in 5NF if it is in 4NF and not contains any join
dependency and joining should be lossless.
o 5NF is satisfied when all the tables are broken into as many tables as
possible in order to avoid redundancy.
o 5NF is also known as Project-join normal form (PJ/NF).

Page | 16
Normalization UNIT-V

Example
SUBJECT LECTURER SEMESTER

Computer Anshika Semester 1

Computer John Semester 1

Math John Semester 1

Math Akash Semester 2

Chemistry Praveen Semester 1

In the above table, John takes both Computer and Math class for Semester
1 but he doesn't take Math class for Semester 2. In this case, combination
of all these fields required to identify a valid data.
Suppose we add a new Semester as Semester 3 but do not know about the
subject and who will be taking that subject so we leave Lecturer and
Subject as NULL. But all three columns together acts as a primary key, so we
can't leave other two columns blank.
So to make the above table into 5NF, we can decompose it into three
relations P1, P2 & P3:
P1

SEMESTER SUBJECT

Semester 1 Computer

Semester 1 Math

Semester 1 Chemistry

Semester 2 Math

P2

SUBJECT LECTURER

Computer Anshika

Page | 17
Normalization UNIT-V

Computer John

Math John

Math Akash

Chemistry Praveen

P3

SEMSTER LECTURER

Semester 1 Anshika

Semester 1 John

Semester 1 John

Semester 2 Akash

Semester 1 Praveen

Page | 18
Structured Query Language (SQL) UNIT-V

SQL
SQL (Structured Query Language) is used to perform operations on the
records stored in the database, such as updating records, inserting records,
deleting records, creating and modifying database tables, views, etc.
SQL is not a database system, but it is a query language.
Suppose you want to perform the queries of SQL language on the stored
data in the database. You are required to install any database management
system in your systems, for example, Oracle, MySQL, MongoDB,
PostgreSQL, SQL Server, DB2, etc.
What is SQL?
SQL is a short-form of the structured query language, and it is pronounced
as S-Q-L or sometimes as See-Quell.
This database language is mainly designed for maintaining the data in
relational database management systems. It is a special tool used by data
professionals for handling structured data (data which is stored in the form
of tables). It is also designed for stream processing in RDSMS.
You can easily create and manipulate the database, access and modify the
table rows and columns, etc. This query language became the standard of
ANSI in the year of 1986 and ISO in the year of 1987.
Why SQL?
Nowadays, SQL is widely used in data science and analytics. Following are
the reasons which explain why it is widely used:
o The basic use of SQL for data professionals and SQL users is to insert,
update, and delete the data from the relational database.
o SQL allows the data professionals and users to retrieve the data from
the relational database management systems.
o It also helps them to describe the structured data.
o It allows SQL users to create, drop, and manipulate the database and
its tables.
o It also helps in creating the view, stored procedure, and functions in
the relational database.
o It allows you to define the data and modify that stored data in the
relational database.

Page | 19
Structured Query Language (SQL) UNIT-V

o It also allows SQL users to set the permissions or constraints on table


columns, views, and stored procedures.
History of SQL
"A Relational Model of Data for Large Shared Data Banks" was a paper
which was published by the great computer scientist "E.F. Codd" in 1970.
The IBM researchers Raymond Boyce and Donald Chamberlin originally
developed the SEQUEL (Structured English Query Language) after learning
from the paper given by E.F. Codd. They both developed the SQL at the San
Jose Research laboratory of IBM Corporation in 1970.
At the end of the 1970s, relational software Inc. developed their own first
SQL using the concepts of E.F. Codd, Raymond Boyce, and Donald
Chamberlin. This SQL was totally based on RDBMS. Relational Software Inc.,
which is now known as Oracle Corporation, introduced the Oracle V2 in
June 1979, which is the first implementation of SQL language. This Oracle
V2 version operates on VAX computers.
Process of SQL
When we are executing the command of SQL on any Relational database
management system, then the system automatically finds the best routine
to carry out our request, and the SQL engine determines how to interpret
that particular command.
Structured Query Language contains the following four components in its
process:
o Query Dispatcher
o Optimization Engines
o Classic Query Engine
o SQL Query Engine, etc.
A classic query engine allows data professionals and users to maintain non-
SQL queries. The architecture of SQL is shown in the following diagram:

Page | 20
Structured Query Language (SQL) UNIT-V

Some SQL Commands


The SQL commands help in creating and managing the database. The most
common SQL commands which are highly used are mentioned below:
1. CREATE command
2. UPDATE command
3. DELETE command
4. SELECT command
5. DROP command
6. INSERT command
CREATE Command
This command helps in creating the new database, new table, table view,
and other objects of the database.
UPDATE Command
This command helps in updating or changing the stored data in the
database.
DELETE Command
This command helps in removing or erasing the saved records from the
database tables. It erases single or multiple tuples from the tables of the
database.

Page | 21
Structured Query Language (SQL) UNIT-V

SELECT Command
This command helps in accessing the single or multiple rows from one or
multiple tables of the database. We can also use this command with the
WHERE clause.
DROP Command
This command helps in deleting the entire table, table view, and other
objects from the database.

INSERT Command
This command helps in inserting the data or records into the database
tables. We can easily insert the records in single as well as multiple rows of
the table.
Advantages of SQL
SQL provides various advantages which make it more popular in the field of
data science. It is a perfect query language which allows data professionals
and users to communicate with the database. Following are the best
advantages or benefits of Structured Query Language:
1. No programming needed
SQL does not require a large number of coding lines for managing the
database systems. We can easily access and maintain the database by using
simple SQL syntactical rules. These simple rules make the SQL user-friendly.
2. High-Speed Query Processing
A large amount of data is accessed quickly and efficiently from the
database by using SQL queries. Insertion, deletion, and updation operations
on data are also performed in less time.
3. Standardized Language
SQL follows the long-established standards of ISO and ANSI, which offer a
uniform platform across the globe to all its users.
4. Portability
The structured query language can be easily used in desktop computers,
laptops, tablets, and even smartphones. It can also be used with other
applications according to the user's requirements.
5. Interactive language
We can easily learn and understand the SQL language. We can also use this
language for communicating with the database because it is a simple query
language. This language is also used for receiving the answers to complex
queries in a few seconds.

Page | 22
Structured Query Language (SQL) UNIT-V

6. More than one Data View


The SQL language also helps in making the multiple views of the database
structure for the different database users.
Disadvantages of SQL
With the advantages of SQL, it also has some disadvantages, which are as
follows:
1. Cost
The operation cost of some SQL versions is high. That's why some
programmers cannot use the Structured Query Language.
2. Interface is Complex
Another big disadvantage is that the interface of Structured query language
is difficult, which makes it difficult for SQL users to use and manage it.
3. Partial Database control
The business rules are hidden. So, the data professionals and users who are
using this query language cannot have full database control.
SQL Syntax
When you want to do some operations on the data in the database, then
you must have to write the query in the predefined syntax of SQL.
The syntax of the structured query language is a unique set of rules and
guidelines, which is not case-sensitive. Its Syntax is defined and maintained
by the ISO and ANSI standards.
Following are some most important points about the SQL syntax which are
to remember:
o You can write the keywords of SQL in both uppercase and lowercase,
but writing the SQL keywords in uppercase improves the readability
of the SQL query.
o SQL statements or syntax are dependent on text lines. We can place a
single SQL statement on one or multiple text lines.
o You can perform most of the action in a database with SQL
statements.
o SQL syntax depends on relational algebra and tuple relational
calculus.

Page | 23
Structured Query Language (SQL) UNIT-V

SQL Statement
SQL statements tell the database what operation you want to perform on
the structured data and what information you would like to access from the
database.
The statements of SQL are very simple and easy to use and understand.
They are like plain English but with a particular syntax.
Simple Example of SQL statement:
1. SELECT "column_name" FROM "table_name";
Each SQL statement begins with any of the SQL keywords and ends with
the semicolon (;). The semicolon is used in the SQL for separating the
multiple Sql statements which are going to execute in the same call. In this
SQL tutorial, we will use the semicolon (;) at the end of each SQL query or
statement.
Most Important SQL Commands and
Statements
1. Select Statement
2. Update Statement
3. Delete Statement
4. Create Table Statement
5. Alter Table Statement
6. Drop Table Statement
7. Create Database Statement
8. Drop Database Statement
9. Insert Into Statement
10. Truncate Table Statement
11. Describe Statement
12. Distinct Clause
13. Commit Statement
14. Rollback Statement
15. Create Index Statement
16. Drop Index Statement
17. Use Statement

Page | 24
Structured Query Language (SQL) UNIT-V

Let's discuss each statement in short one by one with syntax and one
example:
1. SELECT Statement
This SQL statement reads the data from the SQL database and shows it as
the output to the database user.
Syntax of SELECT Statement:
SELECT column_name1, column_name2, .…, column_nameN
[ FROM table_name ]
[ WHERE condition ]
[ ORDER BY order_column_name1 [ ASC | DESC ], .... ];
Example of SELECT Statement:
SELECT Emp_ID, First_Name, Last_Name, Salary, City
FROM Employee_details
WHERE Salary = 100000
ORDER BY Last_Name
This example shows the Emp_ID, First_Name, Last_Name, Salary, and
City of those employees from the Employee_details table
whose Salary is 100000. The output shows all the specified details
according to the ascending alphabetical order of Last_Name.
3. UPDATE Statement
This SQL statement changes or modifies the stored data in the SQL
database.
Syntax of UPDATE Statement:
UPDATE table_name
SET column_name1 = new_value_1, column_name2 = new_value_2, ...., colu
mn_nameN = new_value_N
[ WHERE CONDITION ];
Example of UPDATE Statement:
UPDATE Employee_details
SET Salary = 100000
WHERE Emp_ID = 10;
This example changes the Salary of those employees of
the Employee_details table whose Emp_ID is 10 in the table.
3. DELETE Statement
This SQL statement deletes the stored data from the SQL database.

Page | 25
Structured Query Language (SQL) UNIT-V

Syntax of DELETE Statement:


DELETE FROM table_name
[ WHERE CONDITION ];
Example of DELETE Statement:
DELETE FROM Employee_details
WHERE First_Name = 'Sumit';
This example deletes the record of those employees from
the Employee_details table whose First_Name is Sumit in the table.
4. CREATE TABLE Statement
This SQL statement creates the new table in the SQL database.
Syntax of CREATE TABLE Statement:
CREATE TABLE table_name
(
column_name1 data_type [column1 constraint(s)],
column_name2 data_type [column2 constraint(s)],
.....
.....,
column_nameN data_type [columnN constraint(s)],
PRIMARY KEY(one or more col)
);
Example of CREATE TABLE Statement:
CREATE TABLE Employee_details(
Emp_Id NUMBER(4) NOT NULL,
First_name VARCHAR(30),
Last_name VARCHAR(30),
Salary Money,
City VARCHAR(30),
PRIMARY KEY (Emp_Id)
);
This example creates the table Employee_details with five columns or
fields in the SQL database. The fields in the table are Emp_Id, First_Name,
Last_Name, Salary, and City. The Emp_Id column in the table acts as
a primary key, which means that the Emp_Id column cannot contain
duplicate values and null values.

Page | 26
Structured Query Language (SQL) UNIT-V

5. ALTER TABLE Statement


This SQL statement adds, deletes, and modifies the columns of the table in
the SQL database.
Syntax of ALTER TABLE Statement:
ALTER TABLE table_name ADD column_name datatype[(size)];
The above SQL alter statement adds the column with its datatype in the
existing database table.
ALTER TABLE table_name MODIFY column_name column_datatype[(size)];

The above 'SQL alter statement' renames the old column name to the new
column name of the existing database table.
ALTER TABLE table_name DROP COLUMN column_name;
The above SQL alter statement deletes the column of the existing database
table.
Example of ALTER TABLE Statement:
ALTER TABLE Employee_details
ADD Designation VARCHAR(18);
This example adds the new field whose name is Designation with size 18 in
the Employee_details table of the SQL database.
6. DROP TABLE Statement
This SQL statement deletes or removes the table and the structure, views,
permissions, and triggers associated with that table.
Syntax of DROP TABLE Statement:
DROP TABLE [ IF EXISTS ]
table_name1, table_name2, ……, table_nameN;
The above syntax of the drop statement deletes specified tables completely
if they exist in the database.
Example of DROP TABLE Statement:
DROP TABLE Employee_details;
This example drops the Employee_details table if it exists in the SQL
database. This removes the complete information if available in the table.
7. CREATE DATABASE Statement
This SQL statement creates the new database in the database management
system.
Syntax of CREATE DATABASE Statement:
CREATE DATABASE database_name;

Page | 27
Structured Query Language (SQL) UNIT-V

Example of CREATE DATABASE Statement:


CREATE DATABASE Company;
The above example creates the company database in the system.
8. DROP DATABASE Statement
This SQL statement deletes the existing database with all the data tables
and views from the database management system.
Syntax of DROP DATABASE Statement:
DROP DATABASE database_name;
Example of DROP DATABASE Statement:
DROP DATABASE Company;
The above example deletes the company database from the system.
9. INSERT INTO Statement
This SQL statement inserts the data or records in the existing table of the
SQL database. This statement can easily insert single and multiple records
in a single query statement.
Syntax of insert a single record:
INSERT INTO table_name
(
column_name1,
column_name2, .…,
column_nameN
)
VALUES
(value_1,
value_2, ..…,
value_N
);
Example of insert a single record:
INSERT INTO Employee_details
(
Emp_ID,
First_name,
Last_name,
Salary,

Page | 28
Structured Query Language (SQL) UNIT-V

City
)
VALUES
(101,
Akhil,
Sharma,
40000,
Bangalore
);
This example inserts 101 in the first column, Akhil in the second
column, Sharma in the third column, 40000 in the fourth column,
and Bangalore in the last column of the table Employee_details.
Syntax of inserting a multiple records in a single query:
INSERT INTO table_name
( column_name1, column_name2, .…, column_nameN)
VALUES (value_1, value_2, ..…, value_N), (value_1, value_2, ..…, value_N),….;
Example of inserting multiple records in a single query:
INSERT INTO Employee_details
( Emp_ID, First_name, Last_name, Salary, City )
VALUES (101, Amit, Gupta, 50000, Mumbai), (101, John, Aggarwal, 45000,
Calcutta), (101, Sidhu, Arora, 55000, Mumbai);
This example inserts the records of three employees in
the Employee_details table in the single query statement.
10. TRUNCATE TABLE Statement
This SQL statement deletes all the stored records from the table of the SQL
database.
Syntax of TRUNCATE TABLE Statement:
TRUNCATE TABLE table_name;
Example of TRUNCATE TABLE Statement:
TRUNCATE TABLE Employee_details;
This example deletes the record of all employees from the Employee_details
table of the database.
11. DESCRIBE Statement
This SQL statement tells something about the specified table or view in the
query.

Page | 29
Structured Query Language (SQL) UNIT-V

Syntax of DESCRIBE Statement:


DESCRIBE table_name | view_name;
Example of DESCRIBE Statement:
DESCRIBE Employee_details;
This example explains the structure and other details about
the Employee_details table.
12. DISTINCT Clause
This SQL statement shows the distinct values from the specified columns of
the database table. This statement is used with the SELECT keyword.
Syntax of DISTINCT Clause:
SELECT DISTINCT column_name1, column_name2, ...
FROM table_name;
Example of DISTINCT Clause:
SELECT DISTINCT City, Salary
FROM Employee_details;
This example shows the distinct values of the City and Salary column from
the Employee_details table.
13. COMMIT Statement
This SQL statement saves the changes permanently, which are done in the
transaction of the SQL database.
Syntax of COMMIT Statement:
COMMIT
Example of COMMIT Statement:
DELETE FROM Employee_details
WHERE salary = 30000;
COMMIT;
This example deletes the records of those employees
whose Salary is 30000 and then saves the changes permanently in the
database.
14. ROLLBACK Statement
This SQL statement undo the transactions and operations which are not yet
saved to the SQL database.
Syntax of ROLLBACK Statement:
ROLLBACK
Example of ROLLBACK Statement:
DELETE FROM Employee_details
Page | 30
Structured Query Language (SQL) UNIT-V

WHERE City = Mumbai;


ROLLBACK;
This example deletes the records of those employees
whose City is Mumbai and then undo the changes in the database.
15. CREATE INDEX Statement
This SQL statement creates the new index in the SQL database table.
Syntax of CREATE INDEX Statement:
CREATE INDEX index_name
ON table_name ( column_name1, column_name2, …, column_nameN );
Example of CREATE INDEX Statement:
CREATE INDEX idx_First_Name
ON employee_details (First_Name);
This example creates an index idx_First_Name on the First_Name column
of the Employee_details table.
16. DROP INDEX Statement
This SQL statement deletes the existing index of the SQL database table.
Syntax of DROP INDEX Statement:
DROP INDEX index_name;
Example of DROP INDEX Statement:
DROP INDEX idx_First_Name;
This example deletes the index idx_First_Name from the SQL database.
17. USE Statement
This SQL statement selects the existing SQL database. Before performing
the operations on the database table, you have to select the database from
the multiple existing databases.
Syntax of USE Statement:
USE database_name;
Example of USE DATABASE Statement:
USE Company;
This example uses the company database.

Page | 31
Data persistence using Spring JDBC UNIT-V

Spring Boot JPA


What is JPA?
Spring Boot JPA is a Java specification for managing relational data in
Java applications. It allows us to access and persist data between Java
object/ class and relational database. JPA follows Object-Relation
Mapping (ORM). It is a set of interfaces. It also provides a
runtime EntityManager API for processing queries and transactions on the
objects against the database. It uses a platform-independent object-
oriented query language JPQL (Java Persistent Query Language).
In the context of persistence, it covers three areas:
o The Java Persistence API
o Object-Relational metadata
o The API itself, defined in the persistence package
JPA is not a framework. It defines a concept that can be implemented by
any framework.
Why should we use JPA?
JPA is simpler, cleaner, and less labor-intensive than JDBC, SQL, and hand-
written mapping. JPA is suitable for non-performance oriented complex
applications. The main advantage of JPA over JDBC is that, in JPA, data is
represented by objects and classes while in JDBC data is represented by
tables and records. It uses POJO to represent persistent data that simplifies
database programming. There are some other advantages of JPA:
o JPA avoids writing DDL in a database-specific dialect of SQL. Instead
of this, it allows mapping in XML or using Java annotations.
o JPA allows us to avoid writing DML in the database-specific dialect of
SQL.
o JPA allows us to save and load Java objects and graphs without any
DML language at all.
o When we need to perform queries JPQL, it allows us to express the
queries in terms of Java entities rather than the (native) SQL table and
columns.
JPA Features
There are following features of JPA:
o It is a powerful repository and custom object-mapping abstraction.

Page | 32
Data persistence using Spring JDBC UNIT-V

o It supports for cross-store persistence. It means an entity can be


partially stored in MySQL and Neo4j (Graph Database Management
System).
o It dynamically generates queries from queries methods name.
o The domain base classes provide basic properties.
o It supports transparent auditing.
o Possibility to integrate custom repository code.
o It is easy to integrate with Spring Framework with the custom
namespace.
JPA Architecture
JPA is a source to store business entities as relational entities. It shows how
to define a POJO as an entity and how to manage entities with relation.
The following figure describes the class-level architecture of JPA that
describes the core classes and interfaces of JPA that is defined in the javax
persistence package. The JPA architecture contains the following units:
o Persistence: It is a class that contains static methods to obtain an
EntityManagerFactory instance.
o EntityManagerFactory: It is a factory class of EntityManager. It
creates and manages multiple instances of EntityManager.
o EntityManager: It is an interface. It controls the persistence
operations on objects. It works for the Query instance.
o Entity: The entities are the persistence objects stores as a record in
the database.
o Persistence Unit: It defines a set of all entity classes. In an
application, EntityManager instances manage it. The set of entity
classes represents the data contained within a single data store.
o EntityTransaction: It has a one-to-one relationship with the
EntityManager class. For each EntityManager, operations are
maintained by EntityTransaction class.
o Query: It is an interface that is implemented by each JPA vendor to
obtain relation objects that meet the criteria.

Page | 33
Data persistence using Spring JDBC UNIT-V

JPA Class Relationships


The classes and interfaces that we have discussed above maintain a
relationship. The following figure shows the relationship between classes
and interfaces.

Page | 34
Data persistence using Spring JDBC UNIT-V

o The relationship between EntityManager and EntiyTransaction is one-


to-one. There is an EntityTransaction instance for each EntityManager
operation.
o The relationship between EntityManageFactory and EntiyManager
is one-to-many. It is a factory class to EntityManager instance.
o The relationship between EntityManager and Query is one-to-many.
We can execute any number of queries by using an instance of
EntityManager class.
o The relationship between EntityManager and Entity is one-to-many.
An EntityManager instance can manage multiple Entities.
JPA Implementations
JPA is an open-source API. There is various enterprises vendor such as
Eclipse, RedHat, Oracle, etc. that provides new products by adding the JPA
in them. There are some popular JPA implementations frameworks such
as Hibernate, EclipseLink, DataNucleus, etc. It is also known as Object-
Relation Mapping (ORM) tool.
Object-Relation Mapping (ORM)
In ORM, the mapping of Java objects to database tables, and vice-versa is
called Object-Relational Mapping. The ORM mapping works as a bridge
between a relational database (tables and records) and Java
application (classes and objects).
In the following figure, the ORM layer is an adapter layer. It adapts the
language of object graphs to the language of SQL and relation tables.

Page | 35
Data persistence using Spring JDBC UNIT-V

The ORM layer exists between the application and the database. It converts
the Java classes and objects so that they can be stored and managed in a
relational database. By default, the name that persists become the name of
the table, and fields become columns. Once an application sets-up, each
table row corresponds to an object.
JPA Versions
Earlier versions of EJB defines the persistence layer combined with the
business logic layer using javax.ejb.EntityBean Interface. EJB specification
includes the definition of JPA.
While introducing EJB 3.0, the persistence layer was separated and specified
as JPA 1.0 (Java Persistence API). The specifications of this API were released
along with the specifications of JAVA EE5 on May 11, 2006, using JSR 220.
In 2019, JPA renamed to Jakarta Persistence. The latest version of JPA
is 2.2. It supports the following features:
o Java 8, data and time API
o CDI Injection in AttributeConvertes
o It makes annotations @Repeatable
Difference between JPA and Hibernate
JPA: JPA is a Java specification that is used to access, manage, and persist
data between Java object and relational database. It is a standard approach
for ORM.
Hibernate: It is a lightweight, open-source ORM tool that is used to store
Java objects in the relational database system. It is a provider of JPA. It
follows a common approach provided by JPA.
The following table describes the differences between JPA and Hibernate.

JPA Hibernate

JPA is a Java specification for mapping Hibernate is an ORM


relation data in Java application. framework that deals with data
persistence.

JPA does not provide any implementation It provides implementation classes.


classes.

It uses platform-independent query It uses its own query language


language called JPQL (Java Persistence called HQL (Hibernate Query
Query Language). Language).

Page | 36
Data persistence using Spring JDBC UNIT-V

It is defined in javax.persistence package. It is defined


in org.hibernate package.

It is implemented in various ORM tools Hibernate is the provider of JPA.


like Hibernate, EclipseLink, etc.

JPA uses EntityManager for handling the In Hibernate uses Session for
persistence of data. handling the persistence of data.

Spring Boot Starter Data JPA


Spring Boot provides starter dependency spring-boot-starter-data-jpa to
connect Spring Boot application with relational database efficiently. The
spring-boot-starter-data-jpa internally uses the spring-boot-jpa
dependency.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
Spring Boot JPA Example
Let's create a Spring Boot application that uses JPA to connect to the
database. In the following example, we have used in-memory
database Apache Derby.
Apache Derby: It is an open-source, embedded relational database
implemented entirely in Java. It is available under the Apache License 2.0.
There are following advantages of Apache Derby:
o It is easy to install, deploy, and use.
o It is based on Java, JDBC, and SQL standards.
o It provides an embedded JDBC driver that allows us to embed Derby
in any Java-based solution.
o It also supports client/server mode with the Derby Network Client
JDBC driver, and Derby Network Server.
Spring Boot can auto-configure an embedded database such as H2,
HSQL, and Derbydatabases. We do not need to provide any connection
URLs. We need only include a build dependency on the embedded
database that we want to use.

Page | 37
Data persistence using Spring JDBC UNIT-V

In Spring Boot, we can easily integrate Apache Derby database just by


adding Derby dependency in pom.xml file.
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
Step 1: Open Spring Initializr https://start.spring.io/.
Step 2: Select the latest version of Spring Boot 2.3.0(SNAPSHOT)
Step 3: Provide the Group name. We have provided com.javatpoint.
Step 4: Provide the Artifact Id. We have provided apache-derby-example.
Step 5: Add the dependencies: Spring Web, Spring Data
JPA, and Apache Derby Database.
Step 6: Click on the Generate button. When we click on the Generate
button, it wraps the project in a Jar file and downloads it to the local
system.

Step 7: Extract the Jar file and paste it into the STS workspace.
Step 8: Import the project folder into STS.

Page | 38
Data persistence using Spring JDBC UNIT-V

File -> Import -> Existing Maven Projects -> Browse -> Select the folder
apache-derby-example -> Finish
It takes some time to import.
Step 9: Create a package with the name com.javatpoint.model in the
folder src/main/java.
Step 10: Create a class with the name UserRecord in the
package com.javatpoint.model and do the following:
o Define three variables id, name, and email.
o Generate Getters and Setter.
Right-click on the file -> Source -> Generate Getters and Setters
o Define a default constructor.
o Mark the class as an Entity by using the annotation @Entity.
oMark Id as the primary key by using the annotation @Id.
UserRecord.java
package com.javatpoint.model;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class UserRecord
{
@Id
private int id;
private String name;
private String email;
//default conatructor
public UserRecord()
{
}
public int getId()
{
return id;
}
public void setId(int id)
{

Page | 39
Data persistence using Spring JDBC UNIT-V

this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
}
Step 11: Create a package with the name com.javatpoint.controller in the
folder src/main/java.
Step 12: Create a Controller class with the name UserController in the
package com.javatpoint.controller and do the following:
o Mark the class as a controller by using the annotation @RestController.
o Autowired the class UserService by using the
annotation @Autowired.
o We have defined two mappings, one for getting all users and the
other for add-user.
UserController.java
package com.javatpoint.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

Page | 40
Data persistence using Spring JDBC UNIT-V

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.javatpoint.model.UserRecord;
import com.javatpoint.service.UserService;
import java.util.List;
@RestController
public class UserController
{
@Autowired
private UserService userService;
@RequestMapping("/")
public List<UserRecord> getAllUser()
{
return userService.getAllUsers();
}
@RequestMapping(value="/add-user", method=RequestMethod.POST)
public void addUser(@RequestBody UserRecord userRecord)
{
userService.addUser(userRecord);
}
}
Step 13: Create a package with the name com.javatpoint.service in the
folder src/main/java.
Step 14: Create a Service class with the name UserService in the
package com.javatpoint.service and do the following:
o Mark the class as service by using the annotation @Service.
o Autowired the UserRepository
o Define a method getAllUsers() that returns a List of
oDefine another method name addUser() that saves the user record.
UserService.java
package com.javatpoint.service;
import java.util.List;
import java.util.ArrayList;

Page | 41
Data persistence using Spring JDBC UNIT-V

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.javatpoint.model.UserRecord;
import com.javatpoint.repository.UserRepository;
@Service
public class UserService
{
@Autowired
private UserRepository userRepository;
public List<UserRecord> getAllUsers()
{
List<UserRecord>userRecords = new ArrayList<>();
userRepository.findAll().forEach(userRecords::add);
return userRecords;
}
public void addUser(UserRecord userRecord)
{
userRepository.save(userRecord);
}
}
Step 15: Create a package with the name com.javatpoint.repository in
the folder src/main/java.
Step 16: Create a repository interface with the name UserRepository in the
package com.javatpoint.repository and extends CrudRepository.
UserRepository.java
package com.javatpoint.repository;
import org.springframework.data.repository.CrudRepository;
import com.javatpoint.model.UserRecord;
public interface UserRepository extends CrudRepository<UserRecord, Stri
ng>
{
}
Step 17: Now, open the ApacheDerbyExampleApplication.java file. It
created by default when we set-up an application.
Page | 42
Data persistence using Spring JDBC UNIT-V

ApacheDerbyExampleApplication.java
package com.javatpoint;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ApacheDerbyExampleApplication
{
public static void main(String[] args)
{
SpringApplication.run(ApacheDerbyExampleApplication.class, args);
}
}
Now, we have set-up all the necessary classes and packages according to
the requirements. Notice that we have not provided any connection
URL for the database. After completing all the above steps, the project
directory looks like the following:

Let's run the application.


Step 18: Open the ApacheDerbyExampleApplication.java file and run it
as Java Application.

Page | 43
Data persistence using Spring JDBC UNIT-V

Step 19: Open the browser and invoke the URL http://localhost:8080/. It
returns an empty list because we have not added any user in the List.
To add a user to the database, we will send a POST request by using
the Postman.
Step 20: Open the Postman and do the following:
o Select the POST
o Invoke the URL http://localhost:8080/add-user.
o Click on the Body
o Select Content-Type as JSON(application/json).
o Insert the data which want to insert in the database. We have inserted
the following data:
{
"id": "001",
"name": "Tom",
"email": "[email protected]"
}
o Click on the Send button.

When we click on the Send button, it shows Status:200 OK. It means the
request has been successfully executed.
Step 21: Open the browser and invoke the URL http://localhost:8080. It
returns the user that we have inserted in the database.

Page | 44
Agile Development Principles UNIT-V

Agile Methodology
An agile methodology is an iterative approach to
software development. Each iteration of agile
methodology takes a short time interval of 1 to 4
weeks. The agile development process is aligned
to deliver the changing business requirement. It
distributes the software with faster and fewer
changes.

The single-phase software development takes 6 to 18 months. In single-


phase development, all the requirement gathering and risks management
factors are predicted initially.

The agile software development process frequently takes the feedback of


workable product. The workable product is delivered within 1 to 4 weeks of
iteration.

Page | 45
Agile Development Principles UNIT-V

Roles in Agile
There are two different roles in a Agile methodology. These are the Scrum
Master and Product Owner.

1. Scrum Master
The Scrum Master is a team leader and facility provider who helps the team
member to follow agile practices, so that the team member meets their
commitments and customers requirements. The scrum master plays the
following responsibilities:

o They enable the close co-operation between all the roles and
functions.
o They remove all the blocks which occur.
o They safeguard the team from any disturbances.
o They work with the organization to track the progress and processes
of the company.
o They ensure that Agile Inspect & Adapt processes are leveraged
correctly which includes
o Planned meetings
o Daily stand-ups
o Demo
o Review
o Retrospective meetings, and
o Facilitate team meetings and decision-making process.

2. Product Owner
The Product Owner is one who runs the product from a business
perspective. The Product Owner plays the following responsibilities:

o He defines the requirements and prioritizes their values.


o He sets the release date and contents.

Page | 46
Agile Development Principles UNIT-V

o He takes an active role in iteration and releasing planning meetings.


o He ensures that the team is working on the most valued requirement.
o He represents the voice of the customer.
o He accepts the user stories that meet the definition of done and
defined acceptance criteria.

Cross-functional team
Every agile team contains self-sufficient team with 5 to 9 team members.
The average experience of each member ranges from 6 to 10 years. The
agile team contains 3 to 4 developers, 1 tester, 1 technical lead, 1 scrum
master and 1 product owner.

The Scrum master and Product owner are considered as a part of Team
Interface, on the other hand remaining members are the part of Technical
Interface.

Page | 47
Agile Development Principles UNIT-V

How an Agile Team plan their work?


An Agile methodology is not a specific set of ceremonies or specific
development techniques. Rather, it is a group of methodologies that
demonstrate a commitment to tight feedback cycles and continuous
improvement. An Agile team works in iterations to deliver the customer
requirement, and each iteration takes 10 to 15 days. However, the original
Agile Manifesto didn't set the time period of two-week iterations or an
ideal team size.

Each user requirement is a planned based and their backlog prioritization


and size. The team decides, how much scope they have and how many
hours available with each team to perform their planned task.

What is a user requirement?


The user requirement defines the requirements of the user in terms of
functionalities. There may be of two type of functionality.

o As a <User Role> I want <Functionality> so that <Business Value>


o In order to <Business value> as a <User Role> I want
<Functionality>.

Page | 48
Agile Development Principles UNIT-V

During software release planning, a rough estimate is given to a user


requirement using relative scale points. During iteration planning, the
requirement is broken down into tasks.

Relation between User requirement and Task

o User requirement talks about what is to be done. It defines the needs


of users.
o Task talks about how it is to be done. It defines how functionality is
implemented.
o User requirements are implemented by tasks. Every requirement is
gathering as the task.
o User requirement is divided into different tasks when it is planned in
current iteration.
o User tasks are estimated in hours based, generally it is between 2 to
12 hours.
o Requirements are validated using acceptance test.

Page | 49
Agile Development Principles UNIT-V

When the requirement is completed


The Agile team decides the meaning of task done. There may be different
criteria for it:

o When the entire task (development, testing) are completed.


o When all the acceptance tests are running and are passed.
o When no defects found.
o Product owner has accepted the requirement.
o When the software product is delivered to the end user.

What is Software Acceptance Criteria?


Acceptance Criteria is defined as the functionality, behavior, and
performance required by a product owner. It defines what is to be done so
that the developer knows when a user requirement is complete.

Advantages of Agile Methodology


There are various advantages of using agile methodology over traditional
waterfall model or others. Agile development methodology and testing
practices have worked wonders for numerous organizations with positive
aspects. Its positive aspects are not hidden, it is very much visible in the
organization.

Advantages of Agile Methodology


1. Customer satisfaction is rapid, continuous development and delivery
of useful software.
2. Customer, Developer, and Product Owner interact regularly to
emphasize rather than processes and tools.
3. Product is developed fast and frequently delivered (weeks rather than
months.)
4. A face-to-face conversation is the best form of communication.

Page | 50
Agile Development Principles UNIT-V

5. It continuously gave attention to technical excellence and good


design.
6. Daily and close cooperation between business people and
developers.
7. Regular adaptation to changing circumstances.
8. Even late changes in requirements are welcomed.

Disadvantages of Agile methodology:


1. It is not useful for small development projects.
2. There is a lack of intensity on necessary designing and
documentation.
3. It requires an expert project member to take crucial decisions in the
meeting.
4. Cost of Agile development methodology is slightly more as
compared to other development methodology.
5. The project can quickly go out off track if the project manager is not
clear about requirements and what outcome he/she wants.

Page | 51
Agile Development Principles UNIT-V

Advantages of the Waterfall Model:


1. It is one of the easiest and traditional model to manage. Because of
its traditional development nature, each phase has specific
deliverables and a review process.
2. It works well in smaller size projects where requirements are easily
understandable.
3. It has a faster product delivery model.
4. There are well-documented process and results.
5. Easily adaptable method for shifting teams
6. This project management methodology is beneficial to manage
dependencies.

Disadvantages of Waterfall Model:


1. It is not an ideal model to develop a large scale project size.

Page | 52
Agile Development Principles UNIT-V

2. It requires a clear-cut requirement at the beginning time; otherwise, it


may lead to a less effective method.
3. It is difficult to move back to make changes in the previous phase.
4. The testing process starts once development is completed. Hence, it
has high chances of bugs to be found later in project development.
Due to this, it is costly to fix.

Comparison between the Agile methodology


and Waterfall model:

Agile methodology Waterfall model

It follows the incremental approach. It is a sequential design process.

It divides the project development The software development process


lifecycle into a sprint. is divided into distinct phases.

Agile methodology is a flexible The Waterfall is a structured


methodology. software development
methodology.

Agile is the collection of many different It is completed as one single


projects. project.

The test plan is reviewed after each sprint Test plan is reviewed after complete
development.

Testing team can take part in the It is difficult for the test to initiate
requirements change phase without any change in needs.
problems.

Agile Manifesto
In February 2001, at the Snowbird resort in Utah, a team of 17 software
developers met to discuss lightweight development methods. The result of
their meeting was the following Agile Manifesto for software development:-

Page | 53
Agile Development Principles UNIT-V

We are uncovering the better ways of developing software by doing it and


helping others to do it. Through this meeting, we have come to value -

o Individuals and interactions over Processes and tools.


o Working software over comprehensive documentation.
o Customers are collaboration over contact negotiation.
o Responding to change over following a plan.

So that, while there is value in the items on the right, we value the items on
the left more.

The Twelve Principle of Agile Manifesto


1. Customer Satisfaction: Manifesto provides high priority to satisfy
the costumer's requirements. This is done through early and
continuous delivery of valuable software.
2. Welcome Change: Making changes during software development is
common and inevitable. Every changing requirement should be
welcome, even in the late development phase. Agile process works to
increase the customers' competitive advantage.
3. Deliver the Working Software: Deliver the working software
frequently, ranging from a few weeks to a few months with
considering the shortest time period.
4. Collaboration: Business people (Scrum Master and Project Owner)
and developers must work together during the entire life of a project
development phase.
5. Motivation: Projects should be building around motivated team
members. Provide such environment that supports individual team
members and trust them. It makes them feel responsible for getting
the job done thoroughly.
6. Face-to-face Conversation: Face-to-face conversation between
Scrum Master and development team and between the Scrum Master

Page | 54
Agile Development Principles UNIT-V

and customers for the most efficient and effective method of


conveying information to and within a development team.
7. Measure the Progress as per the Working Software: The working
software is the key and primary measure of the progress.
8. Maintain Constant Pace: The aim of agile development is
sustainable development. All the businesses and users should be able
to maintain a constant pace with the project.
9. Monitoring: Pay regular attention to technical excellence and good
design to maximize agility.
10. Simplicity: Keep things simple and use simple terms to measure the
work that is not completed.
11. Self-organized Teams: The Agile team should be self-organized.
They should not be depending heavily on other teams because the
best architectures, requirements, and designs emerge from self-
organized teams.
12. Review the Work Regularly: The work should be reviewed at regular
intervals, so that the team can reflect on how to become more
productive and adjust its behavior accordingly.

Agile Characteristics
The product developed under agile methodology has seen several
important characteristics that are given below.

Agile Development Releases and Fixed-Length


Iterations
The agile software development method is based on two central units of
delivery: release and iteration. A single version consists of several iterations
phase. Each iteration consists of its micro-project. The different functions of
agile development like defects, enhancement requests and other work
items are organized, estimated, and prioritized, and then assigned to
release.

Page | 55
Agile Development Principles UNIT-V

Agile Development Delivers-Working, Tested


Software
The primary measure of the agile development team is to deliver working,
progress and tested feature software. Working features serve as the basis
for enabling and improving customer feedback. It also serve as team
collaboration, and overall project visibility. They provide such evidence so
that both the system and the project are on track.

At every step of product development, the team continuously works to


assemble on the best business solution. This is done using the latest input
from users, customers, and other stakeholders.

Value-Driven Development
Agile development methodology focuses really on delivering business value
early and continuously. It is measured by running tested software. The
development team focuses on product features as the central unit of
planning, tracking, and delivery.

As the development goes on from iteration to iteration, the team tracks


how many product are running, tested features they are delivering.

Page | 56
Agile Development Principles UNIT-V

Continuous (Adaptive) Planning


As the project launches, the development team does just more planning to
get going with the initial iteration and, if it is appropriate, to lay out a high-
level release plan of features. The single iteration leads the key to
continuous planning.

As the iteration starts, the team choose a set of features to implement,


determines and estimates each technical task for each feature.

Multi-Level Planning in Agile Development


The continuous planning impacts much more significant result if it occurs
on at least two levels:

o At the release level, the development team identifies and prioritize


the features they must have, would like to have, and they can do
within the deadline.
o At the iteration level, development team picks and plan for the next
batch of features to implement, in priority order. If the product
features are too large to estimated or delivered within a single
iteration, the development team break them down further.

Relative Estimation
Several agile development teams use the practice of relative estimation for
features to accelerate planning. It removes unnecessary complexity. The
development team selects a few (3-5) relative estimation categories, or
buckets, and estimates all features in terms of these categories.

The concept of relative estimation or/and predefined estimation buckets


that prevent the team from wasting time on debating. When the product
feature exceeds an agreed maximum estimate, then it should be further
broken down into multiple features.

Page | 57
Agile Development Principles UNIT-V

Emergent Feature Discovery


As disputed to spending weeks or months, analyzing the requirements
before initiating development, agile development projects quickly
prioritized and estimated features, and then refine the details when
required. The feature of the product is described in more detail between
customers, testers, and developers working together.

Continuous Testing
Using continuous testing of software product, we determine the progress
and prevent defects. We handle the running and tested features. Using
continuous testing, we can reduce the failure risk in the project.

Continuous Improvement
Continuous testing and constant improvement are correlated with each
other. While continuous testing, if we found any bugs or project failure, we
continuously improve that bugs immediately. We continuously refine both
the project and the system.

Small, Cross-functional Teams


The incremental software product is delivered at every iteration. The
development teams must also be cross-functional to be successful in
developing the valuable software.

Agile Software Development Life Cycle


(SDLC)
Software development life cycle (SDLC) is a phenomenon
to design, develop and, test high-quality software. The primary aim of SDLC
is to produce high-quality software that fulfills the customer requirement
within times and cost estimates.

Agile Software Development Life Cycle (SDLC) is the combination of both


iterative and incremental process models. It focuses on process adaptability
and customer satisfaction by rapid delivery of working software product.

Page | 58
Agile Development Principles UNIT-V

Agile SDLC breaks down the product into small incremental builds. These
builds are provided into iterations.

In the agile SDLC development process, the customer is able to see the
result and understand whether he/she is satisfied with it or not. This is one
of the advantages of the agile SDLC model. One of its disadvantages is the
absence of defined requirements so, it is difficult to estimate the resources
and development cost.

Each iteration of agile SDLC consists of cross-functional teams working on


various phases:

1. Requirement gathering and analysis


2. Design the requirements
3. Construction/ iteration
4. Deployment
5. Testing
6. Feedback

Page | 59
Agile Development Principles UNIT-V

Requirements gathering and analysis


In this phase, you must define the requirements. You should explain
business opportunities and plan the time and effort needed to build the
project. Based on this information, you can evaluate technical and
economic feasibility.

Design the requirements


When you have identified the project, work with stakeholders to define
requirements. You can use the user flow diagram or the high-level UML
diagram to show the work of new features and show how it will apply to
your existing system.

Construction/ Iteration
When the team defines the requirements, the work begins. The designers
and developers start working on their project. The aims of designers and
developers deploy the working product within the estimated time. The
product will go into various stages of improvement, so it includes simple,
minimal functionality.

Deployment
In this phase, the team issues a product for the user's work environment.

Testing
In this phase, the Quality Assurance team examine the product's
performance and look for the bug.

Feedback
After releasing of the product, the last step is to feedback it. In this step, the
team receives feedback about the product and works through the
feedback.

Page | 60
Agile Development Principles UNIT-V

Agile SDLC Process Flow


1. Concept: Project are imagined and prioritized.
2. Inception: Team members are created, funding is put in place, and
basic environments and requirements are discussed.
3. Iteration/Constriction: The software development team works to
deliver working software. It is based on requirement and feedback.
4. Release: Perform quality assurance (QA) testing, provides internal and
external training, documentation development, and final version of
iteration into the product.
5. Production: It is ongoing support of the software.

Advantages of Agile SDLC


1. Project is divided into short and transparent iterations.
2. It has a flexible change process.
3. It minimizes the risk of software development.

Page | 61
Agile Development Principles UNIT-V

4. Quick release of the first product version.


5. The correctness of functional requirement is implemented into the
development process.
6. Customer can see the result and understand whether he/she is
satisfied with it or not.

Disadvantages of Agile SDLC


1. The development team should be highly professional and client-
oriented.
2. New requirement may be a conflict with the existing architecture.
3. With further correction and change, there may be chances that the
project will cross the expected time.
4. There may be difficult to estimate the final coast of the project due to
constant iteration.
5. A defined requirement is absent.

Page | 62
Deploying Application in Cloud UNIT-V

Cloud Deployment Model


Today, organizations have many exciting opportunities to reimagine,
repurpose and reinvent their businesses with the cloud. The last decade has
seen even more businesses rely on it for quicker time to market, better
efficiency, and scalability. It helps them achieve long-term digital goals as
part of their digital strategy.

Though the answer to which cloud model is an ideal fit for a business
depends on your organization's computing and business needs. Choosing
the right one from the various types of cloud service deployment models is
essential. It would ensure your business is equipped with the performance,
scalability, privacy, security, compliance & cost-effectiveness it requires. It is
important to learn and explore what different deployment types can offer -
around what particular problems it can solve.

Read on as we cover the various cloud computing deployment and service


models to help discover the best choice for your business.

What Is A Cloud Deployment Model?


It works as your virtual computing environment with a choice of
deployment model depending on how much data you want to store and
who has access to the Infrastructure.

Different Types of Cloud Computing Deployment Models


Most cloud hubs have tens of thousands of servers and storage devices to
enable fast loading. It is often possible to choose a geographic area to put
the data "closer" to users. Thus, deployment models for cloud computing
are categorized based on their location. To know which model would best
fit the requirements of your organization, let us first learn about the various
types.

Page | 63
Deploying Application in Cloud UNIT-V

Public Cloud
The name says it all. It is accessible to the public. Public deployment models
in the cloud are perfect for organizations with growing and fluctuating
demands. It also makes a great choice for companies with low-security
concerns. Thus, you pay a cloud service provider for networking services,
compute virtualization & storage available on the public internet. It is also a
great delivery model for the teams with development and testing. Its
configuration and deployment are quick and easy, making it an ideal choice
for test environments.

Page | 64
Deploying Application in Cloud UNIT-V

Benefits of Public Cloud

o Minimal Investment - As a pay-per-use service, there is no large


upfront cost and is ideal for businesses who need quick access to
resources
o No Hardware Setup - The cloud service providers fully fund the entire
Infrastructure
o No Infrastructure Management - This does not require an in-house
team to utilize the public cloud.

Limitations of Public Cloud

o Data Security and Privacy Concerns - Since it is accessible to all, it


does not fully protect against cyber-attacks and could lead to
vulnerabilities.
o Reliability Issues - Since the same server network is open to a wide
range of users, it can lead to malfunction and outages
o Service/License Limitation - While there are many resources you can
exchange with tenants, there is a usage cap.

Private Cloud
Now that you understand what the public cloud could offer you, of course,
you are keen to know what a private cloud can do. Companies that look for
cost efficiency and greater control over data & resources will find the
private cloud a more suitable choice.

It means that it will be integrated with your data center and managed by
your IT team. Alternatively, you can also choose to host it externally. The
private cloud offers bigger opportunities that help meet specific
organizations' requirements when it comes to customization. It's also a wise
choice for mission-critical processes that may have frequently changing
requirements.

Page | 65
Deploying Application in Cloud UNIT-V

Benefits of Private Cloud

o Data Privacy - It is ideal for storing corporate data where only


authorized personnel gets access
o Security - Segmentation of resources within the same Infrastructure
can help with better access and higher levels of security.
o Supports Legacy Systems - This model supports legacy systems that
cannot access the public cloud.

Limitations of Private Cloud

o Higher Cost - With the benefits you get, the investment will also be
larger than the public cloud. Here, you will pay for software,
hardware, and resources for staff and training.
o Fixed Scalability - The hardware you choose will accordingly help you
scale in a certain direction
o High Maintenance - Since it is managed in-house, the maintenance
costs also increase.

Community Cloud
The community cloud operates in a way that is similar to the public cloud.
There's just one difference - it allows access to only a specific set of users
Page | 66
Deploying Application in Cloud UNIT-V

who share common objectives and use cases. This type of deployment
model of cloud computing is managed and hosted internally or by a third-
party vendor. However, you can also choose a combination of all three.

Benefits of Community Cloud

o Smaller Investment - A community cloud is much cheaper than the


private & public cloud and provides great performance
o Setup Benefits - The protocols and configuration of a community
cloud must align with industry standards, allowing customers to work
much more efficiently.

Limitations of Community Cloud

o Shared Resources - Due to restricted bandwidth and storage capacity,


community resources often pose challenges.
o Not as Popular - Since this is a recently introduced model, it is not
that popular or available across industries

Page | 67
Deploying Application in Cloud UNIT-V

Hybrid Cloud
As the name suggests, a hybrid cloud is a combination of two or more
cloud architectures. While each model in the hybrid cloud functions
differently, it is all part of the same architecture. Further, as part of this
deployment of the cloud computing model, the internal or external
providers can offer resources.

Let's understand the hybrid model better. A company with critical data will
prefer storing on a private cloud, while less sensitive data can be stored on
a public cloud. The hybrid cloud is also frequently used for 'cloud bursting'.
It means, supposes an organization runs an application on-premises, but
due to heavy load, it can burst into the public cloud.

Benefits of Hybrid Cloud

o Cost-Effectiveness - The overall cost of a hybrid solution decreases


since it majorly uses the public cloud to store data.
o Security - Since data is properly segmented, the chances of data theft
from attackers are significantly reduced.
o Flexibility - With higher levels of flexibility, businesses can create
custom solutions that fit their exact requirements

Page | 68
Deploying Application in Cloud UNIT-V

Limitations of Hybrid Cloud

o Complexity - It is complex setting up a hybrid cloud since it needs to


integrate two or more cloud architectures
o Specific Use Case - This model makes more sense for organizations
that have multiple use cases or need to separate critical and sensitive
data

A Comparative Analysis of Cloud Deployment Models


With the below table, we have attempted to analyze the key models with an
overview of what each one can do for you:

Important Public Private Community Hybrid


Factors to
Consider

Setup and Easy Requires Requires Requires


ease of use professional professional IT professional IT
IT Team Team Team

Data Security Low High Very High High


and Privacy

Scalability and High High Fixed High


flexibility requirements

Cost- Most Most Cost is Cheaper than


Effectiveness affordable expensive distributed private but
among more expensive
members than public

Reliability Low High Higher High

Making the Right Choice for Cloud Deployment Models


There is no one-size-fits-all approach to picking a cloud deployment model.
Instead, organizations must select a model based on workload-by-

Page | 69
Deploying Application in Cloud UNIT-V

workload. Start with assessing your needs and consider what type of
support your application requires. Here are a few factors you can consider
before making the call:

o Ease of Use - How savvy and trained are your resources? Do you
have the time and the money to put them through training?
o Cost - How much are you willing to spend on a deployment model?
How much can you pay upfront on subscription, maintenance,
updates, and more?
o Scalability - What is your current activity status? Does your system
run into high demand?
o Compliance - Are there any specific laws or regulations in your
country that can impact the implementation? What are the industry
standards that you must adhere to?
o Privacy - Have you set strict privacy rules for the data you gather?

Each cloud deployment model has a unique offering and can immensely
add value to your business. For small to medium-sized businesses, a public
cloud is an ideal model to start with. And as your requirements change, you
can switch over to a different deployment model. An effective strategy can
be designed depending on your needs using the cloud mentioned above
deployment models.

3 Service Models of Cloud Computing


Cloud computing makes it possible to render several services, defined
according to the roles, service providers, and user companies. Cloud
computing models and services are broadly classified as below:

IAAS: Changing Its Hardware Infrastructure on Demand

The Infrastructure as a Service (IAAS) means the hiring & utilizing of the
Physical Infrastructure of IT (network, storage, and servers) from a third-
party provider. The IT resources are hosted on external servers, and users
can access them via an internet connection.

Page | 70
Deploying Application in Cloud UNIT-V

The Benefits

o Time and cost savings: No installation and maintenance of IT


hardware in-house,
o Better flexibility: On-demand hardware resources that can be tailored
to your needs,
o Remote access and resource management.

For Who?

This cloud computing service model is ideal for large accounts, enterprises,
or organizations to build and manage their own IT platforms. However, they
want the flexibility to amend their Infrastructure according to their needs.

PAAS: Providing a Flexible Environment for Your Software


Applications

Platform as a Service (PAAS) allows outsourcing of hardware infrastructure


and software environment, including databases, integration layers,
runtimes, and more.

Page | 71
Deploying Application in Cloud UNIT-V

The Benefits

o Focus on development: Mastering the installation and development


of software applications.
o Time saving and flexibility: no need to manage the implementation of
the platform, instant production.
o Data security: You control the distribution, protection, and backup of
your business data.

For Who?

It is ideal for companies wanting to maintain control over their business


applications. However, they wish to get rid of constraints to manage the
hardware infrastructure and software environment.

SAAS: Releasing the User Experience of Management


Constraints
Software as a Service (SaaS) is provided over the internet and requires no
prior installation. The services can be availed from any part of the world at a
minimal per-month fee.

Page | 72
Deploying Application in Cloud UNIT-V

The Benefits

o You are entirely free from the infrastructure management and


aligning software environment: no installation or software
maintenance.
o You benefit from automatic updates with the guarantee that all users
have the same software version.
o It enables easy and quicker testing of new software solutions.

For Who?

SAAS model accounts for 60% of sales of cloud solutions. Hence, it is


applicable and preferred by most companies.

How does cloud computing work


Assume that you are an executive at a very big corporation. Your particular
responsibilities include to make sure that all of your employees have the
right hardware and software they need to do their jobs. To buy computers
for everyone is not enough. You also have to purchase software as well as
software licenses and then provide these softwares to your employees as
they require. Whenever you hire a new employee, you need to buy more

Page | 73
Deploying Application in Cloud UNIT-V

software or make sure your current software license allows another user. It
is so stressful that you have to spend lots of money.

But, there may be an alternative for executives like you. So, instead of
installing a suite of software for each computer, you just need to load one
application. That application will allow the employees to log-in into a Web-
based service which hosts all the programs for the user that is required for
his/her job. Remote servers owned by another company and that will run
everything from e-mail to word processing to complex data analysis
programs. It is called cloud computing, and it could change the entire
computer industry.

In a cloud computing system, there is a significant workload shift. Local


computers have no longer to do all the heavy lifting when it comes to run
applications. But cloud computing can handle that much heavy load easily
and automatically. Hardware and software demands on the user's side
decrease. The only thing the user's computer requires to be able to run is
the cloud computing interface software of the system, which can be as
simple as a Web browser and the cloud's network takes care of the rest.

Page | 74

You might also like