Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
47 views

Relational Database and SQL

Bst

Uploaded by

barwaliyaheer25
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Relational Database and SQL

Bst

Uploaded by

barwaliyaheer25
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

RELATIONAL DATABASE AND

SQL
Introduction

 A database is defined as an organized


collection of data (Information) about an
entity or things. It is a shared collection
of related data/information used to
support the activities and decision
making of a particular organization.
 It is also allows the users to enter,
access and analyze their data quickly
and easily. It serves as container which
may contain various database objects.
Introduction

 A database can be integrated as


well as shared.
 Database integration is the process
used to aggregate information from
multiple sources—like social media,
sensor data from IoT, data
warehouses, customer transactions,
and more—and share a current,
clean version of it across an
organization.
Introduction

 Shared Databases provide a


synchronized storage location
accessible by multiple concurrent
users.
Components

 Data/Character is the smallest unit


of file organization which represents
itself in the form of a bit that may be
either 0 or 1.
 A field is a set of characters which
are used to represent specific data
elements. It is also termed as a data
item. A specific or an individual data
item within a record is known as a
field.
Components

 A collection of logically related


records is called a file. A file is also
termed as a table or a relation.
 A table has rows and columns, where
rows represent records or tuples and
columns represent the attributes or
fields.
Database Management System-
DBMS
 Database Management System are
specially designed applications that
connect the user and program, and store
data in an organized manner. The
purpose of DBMS software is to allow the
user to create, modify and control a
database.
 A DBMS stores data in such a manner
that it becomes easier and highly
efficient to retrieve, manipulate and
produce information.
Database Management System-
DBMS
 Thus, a DBMS is an electronic or
computerised record-keeping
system.
 Examples of Database Management
Systems are MS-Access, MySql,
PostgreSQL, SQLite, Microsoft SQL
Server, Oracle, SAP etc.
A DBMS gives us tools to:

 Store data in a structured way


 Query the database
 Sort and manipulate the data in the
database
 Validate the data entered and check
for inconsistencies.
 Produced flexible reports both on
screen and on paper.
Need for DBMS
 The database system is used to eliminate the
problems of data redundancy (occurs when the
same piece of data exists in multiple places) and
data inconsistency.
 DataRedundancy
It is defined as the redundancy means duplicate
data and it is also stated that the same parts of
data exist in multiple locations into the database.
This condition is known as Data Redundancy.
 Problems with Data Redundancy :
Here, we will discuss the few problems with data
redundancy as follows.
 Wasted Storage Space.
 More Difficult Database Update.
 It will lead to Data Inconsistency.
 Retrieval of data is slow and inefficient.
Need for DBMS
 Data Inconsistency :
When the same data exists in different
formats in multiple tables. This condition is
known as Data Inconsistency. It means that
different files contain different information
about a particular object or person. This can
cause unreliable and meaningless information.
Data Redundancy leads to Data Inconsistency.
 Example –
If we have an address of someone in many
tables and when we change it in only one
table and in another table it may not be
updated so there is the problem of data
inconsistency may occur.
Need for DBMS

 It does not maintain separate file for


different applications. Rather, It
works on the centrally maintained
database, which means that data is
kept in one place and all applications
that require the data may refer to
this database.
Components of Database
System
 Users: Users can be of varied types,
including a DB administrators,
system or application developers and
end-users.
 DBMS provides the following critical
services to the user:
 A. Database Creation: A DBMS helps
the user in creating and defining the
required data or, in turn a database.
It manages and organizes the
Components of Database
System
 Database Maintenance: It helps in
maintaining the data and databases by
providing operations such addition,
deletion, modification and regular
updating of tables and their records.
 Database Processing: A DBMS performs
one of the major tasks of query
processing- It processes user queries or
the information requirements and
retrives necessary information from the
database.
Components of Database
System
 2. Database Application: Database
application may be Personal,
Departmental, Enterprise and Internal. It
may be general-purpose or customized as
per the needs of a user.
 3. DBMS: Software that allows users to
define, create, access and manage
database is termed as DBMS. For example,
MySql, Oracle etc.
 4. Database: It is a collection of logically
related data.
Advantages of DBMS

 Eliminating of Data Redundancy:


Duplicate of data leads to wastage in storage
space.
 Data Consistency: A DBMS provides data
consistency to a large extent as the changes
made at one place are reflected at all other
places or to all the users.
 Sharing of Data: By using a DBMS, not only
can existing applications share data in the
database, but new applications can also be
developed to operate against the same stored
data.
Advantages of DBMS

 Reduced Programming Effort: A DBMS


saves a lot of programming effort since a
user need not write programs for query
processing involving several tables or
files, report generation, addition,
modification and deletion of data.
 Database Enforces Standards: With
centralized control of the database, the
DBA can ensure that all applicable
standards are followed in the
representation of data.
Advantages of DBMS
 Improved Data Integrity: Data integrity refers
to the validity and consistency of stored data.
 Privacy and Security: Data security refers to
protection of data against accidental or
intentional disclosure to unauthorized persons.
Since there is centralized control, the data is
protected.
 Economical: Combining all the organization’s
operational data into one database and creating
a set of applications that work on this single
source of data can result in cost savings.
Advantages of DBMS

 Improved Backup and Recovery


System: A database system
provides facilities for recovery from
hardware and software failures.
 Meeting Enterprise
Requirements that Individual
Requirements: Since many types of
users with varying levels of technical
knowledge use a database, a DBMS
should provide a variety of user
DBMS Models

 Data models define how the logical


structure of a database is modelled. A
data model is an integrated collection of
conceptual tools that can be used to
describe the structure of the database
along with the appropriate data types,
relationships and constraints required to
be applied on the data. A data model
should be able to give best data
representation and should possess the
following characteristics:
DBMS Models

 1. Data models should be presented


graphically using diagrams and
symbols.
 2. Data representation in a data
model should have no data
redundancy.
 3. A data model should be made
available and shared by various
applications.
 4. Data represented should be
Types of Data Models
Hierarchical Data Model

 In a hierarchical model, records are


organized as trees rather than
graphs, i.e., a hierarchical model
represents a hierarchy of parent and
child data segments. It is
represented by an upside-down
“tree”.
Network data Model

 The Network model is a database


model conceived as a flexible way of
representing objects and their
relationships. It consists of a
collection of records connected to
one another through links.
Relational Data Model

 The most popular data model in


DBMS is the relational model. It is
more scientific and stable model
than hierarchical or network model
since there are no pointers involved
with the records and in case of any
fault or error, this pointers may result
in inconsistency among the records
and can lead to reduced data
integrity.
Relational Data Model

 In this model, data is organized in


two-dimensional tables called
relations. The tables or relations are
related to each other. A relational
database is based on this relational
model developed by E.F Codd
(Edgar Frank "Ted" Codd).
Basic Terminologies
related to a Relational
 1. Entity: An entity is something that exists and
Database:
about which we can store some information. It
is an object which can be distinctly identified.
For e.g. Student entity, employee entity etc.
Entity becomes the name of the table.
2. Attribute: In a relational table, an attribute is
a set of values of a particular type. The term
attribute is also used to represent a column. A
table consists of several records (rows); each
record can be broken down into several small
entities known as fields or attributes or
columns.
 Tuple: Each row in a table is known
as a tuple. It is also called a record
or row. A record in a table represents
a set of related data.
 Cardinality of Relation: It is the
number of records or tuples in the
relation.
 Degree of Relation: Number of
columns or attributes is known as
degree of a relation. Thus the degree
of Student Relation is 4.

 Domain of Relation: It defines the


kind of data represented by the
attribute.

 Body of the Relation:

 There are 10 tuples (cardinality =10,


attribute =4 or degree=4)
 Attribute name: Rollnumber, Name,
Address, Gender
 The domain of the attribute Gender
is (M,F)
Foreign Key:

 A foreign key is a non-key attribute


whose value is derived from the
primary key of another table; in
other words, a primary key in some
other table having relationship with
the current or original table.
Foreign Key:

Employee Department
TID ENam DCod DCode Designatio
e e n
E1 Ankur Mgr Mgr Manager
E2 Dipak Dir Dir Director
E3 Kriti Mgr Mgr Manager
Distinct
Group By Clause

 The Group BY clause can be used in


SELECT statement to collect data
across multiple records and group
the results by one or more columns.
Having clause

 The HAVING clause is used in


combination with GROUP BY clause.
It can be used in a SELECT statement
to filter the records by specifying a
condition which a GROUP BY returns.

You might also like