FSD Unit V
FSD 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
Page | 2
Relational Schemas UNIT-V
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 contains both primary & secondary It also contains both primary &
Keys. secondary keys.
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
Normal Description
Form
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.
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:
14 John 7272826385, UP
9064738238
Page | 9
Normalization UNIT-V
The decomposition of the EMPLOYEE table into 1NF has been shown
below:
14 John 7272826385 UP
14 John 9064738238 UP
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
Page | 11
Normalization UNIT-V
Example:
EMPLOYEE_DETAIL table:
Page | 12
Normalization UNIT-V
EMPLOYEE_ZIP table:
201010 UP Noida
02228 US Boston
60007 US Chicago
06389 UK Norwich
462007 MP Bhopal
Page | 13
Normalization UNIT-V
EMP_ID EMP_COUNTRY
264 India
264 India
EMP_DEPT 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
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
Page | 16
Normalization UNIT-V
Example
SUBJECT LECTURER SEMESTER
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
Page | 20
Structured Query Language (SQL) UNIT-V
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
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
Page | 26
Structured Query Language (SQL) UNIT-V
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
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
Page | 31
Data persistence using Spring JDBC UNIT-V
Page | 32
Data persistence using Spring JDBC UNIT-V
Page | 33
Data persistence using Spring JDBC UNIT-V
Page | 34
Data persistence using Spring JDBC UNIT-V
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
Page | 36
Data persistence using Spring JDBC UNIT-V
JPA uses EntityManager for handling the In Hibernate uses Session for
persistence of data. handling the persistence of data.
Page | 37
Data persistence using Spring JDBC UNIT-V
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:
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.
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:
Page | 46
Agile Development Principles UNIT-V
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
Page | 48
Agile Development Principles UNIT-V
Page | 49
Agile Development Principles UNIT-V
Page | 50
Agile Development Principles UNIT-V
Page | 51
Agile Development Principles UNIT-V
Page | 52
Agile Development Principles UNIT-V
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
So that, while there is value in the items on the right, we value the items on
the left more.
Page | 54
Agile Development Principles UNIT-V
Agile Characteristics
The product developed under agile methodology has seen several
important characteristics that are given below.
Page | 55
Agile Development Principles UNIT-V
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.
Page | 56
Agile Development Principles UNIT-V
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.
Page | 57
Agile Development Principles UNIT-V
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.
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.
Page | 59
Agile Development Principles UNIT-V
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
Page | 61
Agile Development Principles UNIT-V
Page | 62
Deploying Application in Cloud UNIT-V
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.
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
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
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.
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.
Page | 68
Deploying Application in Cloud UNIT-V
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.
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
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.
Page | 71
Deploying Application in Cloud UNIT-V
The Benefits
For Who?
Page | 72
Deploying Application in Cloud UNIT-V
The Benefits
For Who?
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.
Page | 74