Bce Unit 5
Bce Unit 5
DBMS Tutorial provides basic and advanced concepts of Database. Our DBMS Tutorial
is designed for beginners and professionals both.
Database management system is software that is used to manage the database.
Our DBMS Tutorial includes all topics of DBMS such as introduction, ER model, keys,
relational model, join operation, SQL, functional dependency, transaction, concurrency
control, etc.
Characteristics of DBMS
o It uses a digital repository established on a server to store and manage the
information.
o It can provide a clear and logical view of the process that manipulates data.
o DBMS contains automatic backup and recovery procedures.
o It contains ACID properties which maintain data in a healthy state in case of
failure.
o It can reduce the complex relationship between data.
o It is used to support manipulation and processing of data.
o It is used to provide security of data.
o It can view the database from different viewpoints according to the requirements
of the user.
Advantages of DBMS
o Controls database redundancy: It can control data redundancy because it stores
all the data in one single database file and that recorded data is placed in the
database.
o Data sharing: In DBMS, the authorized users of an organization can share the
data among multiple users.
o Easily Maintenance: It can be easily maintainable due to the centralized nature of
the database system.
o Reduce time: It reduces development time and maintenance need.
o Backup: It provides backup and recovery subsystems which create automatic
backup of data from hardware and software failures and restores the data if
required.
o multiple user interface: It provides different types of user interfaces like
graphical user interfaces, application program interfaces
File System:
The file system is basically a way of arranging the files in a storage medium
like a hard disk. The file system organizes the files and helps in the retrieval of
files when they are required. File systems consist of different files which are
grouped into directories. The directories further contain other folders and files.
The file system performs basic operations like management, file naming, giving
access rules, etc.
o Example: NTFS(New Technology File System), EXT(Extended File System).
Example:
Oracle, MySQL, MS SQL server.
Only one user can access data at a Multiple users can access
User Access time. data at a time.
Basis File System DBMS
The user has to write procedures for The user not required to write
Meaning managing databases procedures.
Data Models
Data Model is the modeling of the data description, data semantics, and consistency
constraints of the data. It provides the conceptual tools for describing the design of a
database at each level of data abstraction. Therefore, there are following four data models
used for understanding the structure of the database:
1) Relational Data Model: This type of model designs the data in the form of rows and
columns within a table. Thus, a relational model uses tables for representing data and in-
between relationships. Tables are also called relations. This model was initially described
by Edgar F. Codd, in 1969. The relational data model is the widely used model which is
primarily used by commercial data processing applications.
2) Entity-Relationship Data Model: An ER model is the logical representation of data
as objects and relationships among them. These objects are known as entities, and
relationship is an association among these entities. This model was designed by Peter
Chen and published in 1976 papers. It was widely used in database designing. A set of
attributes describe the entities. For example, student_name, student_id describes the
'student' entity. A set of the same type of entities is known as an 'Entity set', and the set of
the same type of relationships is known as 'relationship set'.
4) Semistructured Data Model: This type of data model is different from the other three
data models (explained above). The semistructured data model allows the data
specifications at places where the individual data items of the same type may have
different attributes sets. The Extensible Markup Language, also known as XML, is
widely used for representing the semistructured data. Although XML was initially
designed for including the markup information to the text document, it gains importance
because of its application in the exchange of data.
5.Hierarchical Model
The hierarchical Model is one of the oldest models in the data model which was
developed by IBM, in the 1950s. In a hierarchical model, data are viewed as a
collection of tables, or we can say segments that form a hierarchical relation. In thi s,
the data is organized into a tree-like structure where each record consists of one parent
record and many children. Even if the segments are connected as a chain-like structure
by logical associations, then the instant structure can be a fan structure with multiple
branches. We call the illogical associations as directional associations.
6. Network Model
The Network Model was formalized by the Database Task group in the 1960s. This
model is the generalization of the hierarchical model. This model can consist of
multiple parent segments and these segments are grouped as levels but there exists a
logical association between the segments belonging to any level. Mostly, there exists a
many-to-many logical association between any of the two segments.
DBMS Architecture
o The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers, database
servers and other components that are connected with networks.
o The client/server architecture consists of many PCs and a workstation which are
connected via the network.
o DBMS architecture depends upon how users are connected to the database to get
their request done.
3-Tier Architecture
o The 3-Tier architecture contains another layer between the client and server. In
this architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which further
communicates with the database system.
o End user has no idea about the existence of the database beyond the application
server. The database also has no idea about any other user beyond the application.
o The 3-Tier architecture is used in case of large web application.
2. Conceptual Level
o The conceptual schema describes the design of a database at the conceptual level.
Conceptual level is also known as logical level.
o The conceptual schema describes the structure of the whole database.
o The conceptual level describes what data are to be stored in the database and also
describes what relationship exists among those data.
o In the conceptual level, internal details such as an implementation of the data
structure are hidden.
o Programmers and database administrators work at this level.
3. External Level
o At the external level, a database contains several schemas that sometimes called as
subschema. The subschema is used to describe the different view of the database.
o An external schema is also known as view schema.
o Each view schema describes the database part that a particular user group is
interested and hides the remaining database from that user group.
o The view schema describes the end user interaction with database systems.
Data Independence
o Data independence can be explained using the three-schema architecture.
o Data independence refers characteristic of being able to modify the schema at one
level of the database system without altering the schema at the next higher level.
All the above information or metadata is stored in a data dictionary. The data dictionary
also maintains updated information whenever they occur in the relations. Such metadata
constitutes a miniature database. Some systems store the metadata in the form of a
relation in the database itself. The system designers design the way of representation of
the data dictionary. Also, a data dictionary stores the data in a non-formalized manner. It
does not use any normal form so as to fastly access the data stored in the dictionary.
For example, in the data dictionary, it uses underline below the value to represent that
the following field contains a primary key.
A database is a storehouse for a large amount of data, which is used in organizations and
firms. A database management system is a program that helps in updating, accessing,
retrieving, representing, and manipulating the data in a database system.
Database administration involves every activity that is performed by an individual to
ensure that a database is available when needed. Maintaining the integrity of a database is
the primary goal of database administration.
A database administrator carries out several activities and operations to ensure the
integrity, security, and availability of the data stored in the database.
1. Candidate Key: The minimal set of attributes that can uniquely identify a tuple
is known as a candidate key. For Example, STUD_NO in STUDENT relation.
• It is a minimal super key.
• It is a super key with no repeated data is called a candidate key.
• The minimal set of attributes that can uniquely identify a record.
• It must contain unique values.
• It can contain NULL values.
• Every table must have at least a single candidate key.
• A table can have multiple candidate keys but only one primary key (the primary
key cannot have a NULL value, so the candidate key with a NULL value can’t be
the primary key).
• The value of the Candidate Key is unique and may be null for a tuple.
• There can be more than one candidate key in a relationship.
Example:
STUD_NO is the candidate key for relation STUDENT.
Table STUDENT
STUD_NO SNAME ADDRESS PHONE
Example:
{STUD_NO, COURSE_NO} is a composite
candidate key for relation STUDENT_COURSE.
Table STUDENT_COURSE
STUD_NO TEACHER_NO COURSE_NO
1 001 C001
2 056 C005
Note: In SQL Server a unique constraint that has a nullable column, allows the value
‘null‘ in that column only once. That’s why the STUD_PHONE attribute is a
candidate here, but can not be a ‘null’ value in the primary key attribute.
2. Primary Key: There can be more than one candidate key in relation out of
which one can be chosen as the primary key. For Example, STUD_NO, as well as
STUD_PHONE, are candidate keys for relation STUDENT but STUD_NO can be
chosen as the primary key (only one out of many candidate keys).
• It is a unique key.
• It can identify only one tuple (a record) at a time.
• It has no duplicate values, it has unique values.
• It cannot be NULL.
• Primary keys are not necessarily to be a single column; more than one column can
also be a primary key for a table.
Example:
STUDENT table -> Student(STUD_NO, SNAME,
ADDRESS, PHONE) , STUD_NO is a primary key
Table STUDENT
STUD_NO SNAME ADDRESS PHONE
3. Super Key: The set of attributes that can uniquely identify a tuple is known as
Super Key. For Example, STUD_NO, (STUD_NO, STUD_NAME), etc. A super key
is a group of single or multiple keys that identifies rows in a table. It supports NULL
values.
• Adding zero or more attributes to the candidate key generates the super key.
• A candidate key is a super key but vice versa is not true.
Example:
Consider the table shown above.
STUD_NO+PHONE is a super key.
4. Alternate Key: The candidate key other than the primary key is called an
alternate key.
• All the keys which are not primary keys are called alternate keys.
• It is a secondary key.
• It contains two or more fields to identify two or more records.
• These values are repeated.
• Eg:- SNAME, and ADDRESS is Alternate keys
Example:
Consider the table shown above.
STUD_NO, as well as PHONE both,
are candidate keys for relation STUDENT but
PHONE will be an alternate key
(only one out of many candidate keys).
5. Foreign Key: If an attribute can only take the values which are present as values
of some other attribute, it will be a foreign key to the attribute to which it refers. The
relation which is being referenced is called referenced relation and the corresponding
attribute is called referenced attribute the relation which refers to the referenced
relation is called referencing relation and the corresponding attribute is called
referencing attribute. The referenced attribute of the referenced relation should be the
primary key to it.
• It is a key it acts as a primary key in one table and it acts as
secondary key in another table.
• It combines two or more relations (tables) at a time.
• They act as a cross-reference between the tables.
• For example, DNO is a primary key in the DEPT table and a non-key in EMP
Example:
Refer Table STUDENT shown above.
STUD_NO in STUDENT_COURSE is a
foreign key to STUD_NO in STUDENT relation.
Table STUDENT_COURSE
STUD_NO TEACHER_NO COURSE_NO
1 005 C001
2 056 C005
It may be worth noting that, unlike the Primary Key of any given relation, Foreign Key
can be NULL as well as may contain duplicate tuples i.e. it need not follow uniqueness
constraint. For Example, STUD_NO in the STUDENT_COURSE relation is not
unique. It has been repeated for the first and third tuples. However, the STUD_NO in
STUDENT relation is a primary key and it needs to be always unique, and it cannot be
null.
6. Composite Key: Sometimes, a table might not have a single column/attribute
that uniquely identifies all the records of a table. To uniquely identify rows of a table, a
combination of two or more columns/attributes can be used. It still can give duplicate
values in rare cases. So, we need to find the optimal set of attributes that can uniquely
identify rows in a table.
• It acts as a primary key if there is no primary key in a table
• Two or more attributes are used together to make a composite key.
• Different combinations of attributes may give different accuracy in terms of
identifying the rows uniquely.
Example:
FULLNAME + DOB can be combined
together to access the details of a student.
SQL Commands
o SQL commands are instructions. It is used to communicate with the database. It is
also used to perform specific tasks, functions, and queries of data.
o SQL can perform various tasks like create a table, add data to tables, drop the
table, modify the table, set permission for users.
Example:
1. CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DO
B DATE);
b. DROP: It is used to delete both the structure and record stored in the table.
Syntax
1. DROP TABLE table_name;
Example
1. DROP TABLE EMPLOYEE;
c. ALTER: It is used to alter the structure of the database. This change could be either to
modify the characteristics of an existing attribute or probably to add a new attribute.
Syntax:
To add a new column in the table
1. ALTER TABLE table_name ADD column_name COLUMN-definition;
To modify existing column in the table:
1. ALTER TABLE table_name MODIFY(column_definitions....);
EXAMPLE
1. ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
2. ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));
d. TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax:
1. TRUNCATE TABLE table_name;
Example:
1. TRUNCATE TABLE EMPLOYEE;
2. Data Manipulation Language
o DML commands are used to modify the database. It is responsible for all form of
changes in the database.
o The command of DML is not auto-committed that means it can't permanently save
all the changes in the database. They can be rollback.
Here are some commands that come under DML:
o INSERT
o UPDATE
o DELETE
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into the row
of a table.
Syntax:
1. INSERT INTO TABLE_NAME
2. (col1, col2, col3,.... col N)
3. VALUES (value1, value2, value3, .... valueN);
Or
1. INSERT INTO TABLE_NAME
2. VALUES (value1, value2, value3, .... valueN);
For example:
1. INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo", "DBMS");
b. UPDATE: This command is used to update or modify the value of a column in the
table.
Syntax:
1. UPDATE table_name SET [column_name1= value1,...column_nameN = valueN] [WHE
RE CONDITION]
For example:
1. UPDATE students
2. SET User_Name = 'Sonoo'
3. WHERE Student_Id = '3'
For example:
1. DELETE FROM javatpoint
2. WHERE Author="Sonoo";
3. Data Control Language
DCL commands are used to grant and take back authority from any database user.
Here are some commands that come under DCL:
o Grant
o Revoke
Example
1. REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
4. Transaction Control Language
TCL commands can only use with DML commands like INSERT, DELETE and
UPDATE only.
These operations are automatically committed in the database that's why they cannot be
used while creating tables or dropping them.
Here are some commands that come under TCL:
o COMMIT
o ROLLBACK
o SAVEPOINT
a. Commit: Commit command is used to save all the transactions to the database.
Syntax:
1. COMMIT;
Example:
1. DELETE FROM CUSTOMERS
2. WHERE AGE = 25;
3. COMMIT;
b. Rollback: Rollback command is used to undo transactions that have not already been
saved to the database.
Syntax:
1. ROLLBACK;
Example:
1. DELETE FROM CUSTOMERS
2. WHERE AGE = 25;
3. ROLLBACK;
c. SAVEPOINT: It is used to roll the transaction back to a certain point without rolling
back the entire transaction.
Syntax:
1. SAVEPOINT SAVEPOINT_NAME;
5. Data Query Language
DQL is used to fetch the data from the database.
It uses only one command:
o SELECT
a. SELECT: This is the same as the projection operation of relational algebra. It is used
to select the attribute based on the condition described by WHERE clause.
Syntax:
1. SELECT expressions
2. FROM TABLES
3. WHERE conditions;
For example:
1. SELECT emp_name
2. FROM employee
3. WHERE age > 20;
Cloud Computing
Cloud Computing tutorial provides basic and advanced concepts of Cloud Computing.
Our Cloud Computing tutorial is designed for beginners and professionals.
Cloud computing is a virtualization-based technology that allows us to create, configure,
and customize applications via an internet connection. The cloud technology includes a
development platform, hard disk, software application, and database.
What is Cloud Computing
The term cloud refers to a network or the internet. It is a technology that uses remote
servers on the internet to store, manage, and access data online rather than local drives.
The data can be anything such as files, images, documents, audio, video, and more.
There are the following operations that we can do using cloud computing:
o Developing new applications and services
o Storage, back up, and recovery of data
o Hosting blogs and websites
o Delivery of software on demand
o Analysis of data
o Streaming videos and audios
4) Multi-Sharing
With the help of cloud computing, multiple users and applications can work more
efficiently with cost reductions by sharing common infrastructure.
6) Maintenance
Maintenance of cloud computing applications is easier, since they do not need to be
installed on each user's computer and can be accessed from different places. So, it
reduces the cost also.
7) Low Cost
By using cloud computing, the cost will be reduced because to take the services of cloud
computing, IT company need not to set its own infrastructure and pay-as-per usage of
resources.
Cloud infrastructure
Cloud Computing which is one of the demanding technology of current scenario and
which has been proved as a revolutionary technology trend for businesses of all sizes.
It manages a broad and complex infrastructure setup to provide cloud services and
resources to the customers. Cloud Infrastructure which comes under the backend part
of cloud architecture represents the hardware and software component such as server,
storage, networking, management software, deployment software and virtualization
software etc. In backend, cloud infrastructure enables the complete cloud computing
system.
Cloud infrastructure components :
Different components of cloud infrastructure supports the computing requirements of a
cloud computing model. Cloud infrastructure has number of key components but not
limited to only server, software, network and storage devices. Still cloud infrastructure
is categorized into three parts in general i.e.
1. Computing
2. Networking
3. Storage
The most important point is that cloud infrastructure should have some basic
infrastructural constraints like transparency, scalability, security and intelligent
monitoring etc.
The below figure represents components of cloud infrastructure
1. Hypervisor :
Hypervisor is a firmware or a low level program which is a key to enable
virtualization. It is used to divide and allocate cloud resources between several
customers. As it monitors and manages cloud services/resources that’s why hypervisor
is called as VMM (Virtual Machine Monitor) or (Virtual Machine Manager).
2. Management Software :
Management software helps in maintaining and configuring the infrastructure. Cloud
management software monitors and optimizes resources, data, applications and
services.
3. Deployment Software :
Deployment software helps in deploying and integrating the application on the cloud.
So, typically it helps in building a virtual computing environment.
4. Network :
It is one of the key component of cloud infrastructure which is responsible for
connecting cloud services over the internet. For the transmission of data and resources
externally and internally network is must required.
5. Server :
Server which represents the computing portion of the cloud infrastructure is
responsible for managing and delivering cloud services for various services and
partners, maintaining security etc.
6. Storage :
Storage represents the storage facility which is provided to different organizations for
storing and managing data. It provides a facility of extracting another resource if one
of the resource fails as it keeps many copies of storage.
Along with this, virtualization is also considered as one of important component of
cloud infrastructure. Because it abstracts the available data storage and computing
power away from the actual hardware and the users interact with their cloud
infrastructure through GUI (Graphical User Interface).
Example: AWS Elastic Beanstalk, Windows Azure, Heroku, Force.com, Google App
Engine, Apache Stratos, Magento Commerce Cloud, and OpenShift.
To know more about PaaS, click here.
• Public Cloud
• Private Cloud
• Hybrid Cloud
• Community Cloud
Public Cloud
The public cloud makes it possible for anybody to access systems and services. The
public cloud may be less secure as it is open to everyone. The public cloud is one in
which cloud infrastructure services are provided over the internet to the general people
or major industry groups. The infrastructure in this cloud model is owned by the entity
that delivers the cloud services, not by the consumer. It is a type of cloud hosting that
allows customers and users to easily access systems and services. This form of cloud
computing is an excellent example of cloud hosting, in which service providers supply
services to a variety of customers. In this arrangement, storage backup and retrieval
services are given for free, as a subscription, or on a per-user basis. For example,
Google App Engine etc.
Private Cloud
The private cloud deployment model is the exact opposite of the public cloud
deployment model. It’s a one-on-one environment for a single user (customer). There is
no need to share your hardware with anyone else. The distinction between private and
public clouds is in how you handle all of the hardware. It is also called the “internal
cloud” & it refers to the ability to access systems and services within a given border or
organization. The cloud platform is implemented in a cloud-based secure environment
that is protected by powerful firewalls and under the supervision of an organization’s IT
department. The private cloud gives greater flexibility of control over cloud resources.
Community Cloud
It allows systems and services to be accessible by a group of organizations. It is a
distributed system that is created by integrating the services of different clouds to
address the specific needs of a community, industry, or business. The infrastructure of
the community could be shared between the organization which has shared concerns or
tasks. It is generally managed by a third party or by the combination of one or more
organizations in the community.
Advantages of the Community Cloud Model
• Cost Effective: It is cost-effective because the cloud is shared by multiple
organizations or communities.
• Security: Community cloud provides better security.
• Shared resources: It allows you to share resources, infrastructure, etc. with
multiple organizations.
• Collaboration and data sharing: It is suitable for both collaboration and data
sharing.
2) Improved collaboration
Cloud applications improve collaboration by allowing groups of people to quickly and
easily share information in the cloud via shared storage.
3) Excellent accessibility
Cloud allows us to quickly and easily access store information anywhere, anytime in the
whole world, using an internet connection. An internet cloud infrastructure increases
organization productivity and efficiency by ensuring that our data is always accessible.
5) Mobility
Cloud computing allows us to easily access all cloud data via mobile.
8) Data security
Data security is one of the biggest advantages of cloud computing. Cloud offers many
advanced features related to security and ensures that data is securely stored and handled.
1) Internet Connectivity
As you know, in cloud computing, every data (image, audio, video, etc.) is stored on the
cloud, and we access these data through the cloud by using the internet connection. If you
do not have good internet connectivity, you cannot access these data. However, we have
no any other way to access data from the cloud.
2) Vendor lock-in
Vendor lock-in is the biggest disadvantage of cloud computing. Organizations may face
problems when transferring their services from one vendor to another. As different
vendors provide different platforms, that can cause difficulty moving from one cloud to
another.
3) Limited Control
As we know, cloud infrastructure is completely owned, managed, and monitored by the
service provider, so the cloud users have less control over the function and execution of
services within a cloud infrastructure.
4) Security
Although cloud service providers implement the best security standards to store
important information. But, before adopting cloud technology, you should be aware that
you will be sending all your organization's sensitive information to a third party, i.e., a
cloud computing service provider. While sending the data on the cloud, there may be a
chance that your organization's information is hacked by Hackers.