0% found this document useful (0 votes)
13 views25 pages

DatabaseConcepts Mine One

Uploaded by

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

DatabaseConcepts Mine One

Uploaded by

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

Database Concepts

Database Concepts
• Collection of interrelated data stored
together to serve multiple applications
• DBMS – collection of interrelated files and
a set of programs that allow users to
access and modify these files
• Operations
▫ Addition
▫ Deletion
▫ Modification
▫ Query
▫ Retrieval
Advantages of Databases
1. Reduce data redundancy
▫ Redundancy leads to:
 Inconsistent data
 Wastage of storage space
2. Control data inconsistency to a large
extent
▫ Inconsistency leads to:
 Incorrect or conflicting information
▫ Propagating updates
 In case of redundancy DBMS updates the
changes made to either of the copies
Continued…
3. Facilitates sharing of data
▫ Users use same piece of data for different
purposes
4. Enforce standards
▫ Company/ organization standards,
industry standards, national /
International standards
▫ Aid to data interchange
Continued…
5. Ensure data security
▫ Data security
 Protection of data against accidental or
intentional disclosure to unauthorized persons
or unauthorized modification or destruction
▫ Privacy of data
 Rights of individuals and organizations to
determine when, how and to what extent
information about them is to be transmitted to
others
▫ Access to data is through proper channel and
by carrying out authorization checks
Continued…
6. Integrity can be maintained
▫ Integrity checks
 Range checks
 Value matching
Relational data model
• Data organized as tables (Relations)
• Each row represents a relationship among a
set of values
• Tuples – Rows of a relation
• Attributes – Columns of a relation
• RDM – collection of tables
• Users query these tables, insert, delete and
modify tuples
• Language – Relational query language
▫ E.g.: Structured Query Language (SQL)
Degree and Cardinality
• Degree
▫ The number of attributes in a relation is
called Degree
• Cardinality
▫ The number of tuples in a relation is known
as Cardinality
View
▫ A view is a virtual table that does not really
exist in its own right but is instead derived
from one or more underlying base tables
Example
• Consider three tables:
▫ Suppliers (Supp#, Supp_name, Status,
City)
▫ Items (Item#, Item _name, Price)
▫ Shipments (Supp#, Item#, Qty_Supplied)
Items
ItemNo ItemName Price

I1 Milk 15.00
I2 Cake 5.00
I3 Bread 9.00
I4 Milk Bread 14.00
I5 Biscuit 6.00
I6 Cream Biscuit 10.00
I7 Ice-cream 16.00
I8 Juice 8.00
I9 Butter 15.00
Suppliers
Supp
Supp_Nam Statu City Supp Item Qty_suppli
# e s # # ed
Shipments
S1 Britannia 10 Delhi S1 I2 10
S2 New 30 Mumbai S I3 20
Bakers S1 I6 20
S3 Mother 10 Delhi
S2 I4 20
Diary
S2 I5 10
S4 Cookz 50 Bangalo
re S3 I1 10
S5 Haldiram 40 Jaipur S3 I7 10
S4 I8 30
S5 I9 30
Types of Keys
• Primary key
• Candidate key
• Alternate key
• Foreign key
Primary key
• Set of one or more attributes that
uniquely identifies tuples within a relation
• Composite primary key - primary consists
of more than one attribute
• Does not have duplicate values within the
relation
• Non-key attributes
Candidate key
• Candidates for primary key position
• All attribute combinations in a relation
that can serve as primary key
• Database analyst decides one of the
candidate key as primary key
Alternate key
• Candidate key that is not the primary key
Foreign key
• Non key attribute whose values are
derived from primary key of some other
table
Structured Query Language
SQL
• Language that enables to create and
operate on relational databases
• Can be used by both casual users and
skilled programmers
Processing capabilities of SQL
 Data definition language (DDL)
 SQL DDL provides commands for defining
relation schemas, deleting relations, creating
indexes and modifying relation schems
 Data manipulation language (DML)
 Includes query language based on both
relational algebra and tuple relational
calculus
 Embedded DML
 Designed to use within general purpose
programming languages like Cobol, C etc
 View definition
 SQL DDL includes commands for defining
views
 Authorization
 SQL DDL includes commands for specifying
access rights to relations and views
 Integrity
 Includes enhanced features for integrity
checking
 Transaction control
 Includes commands for specifying beginning
and ending of transactions
DDL
• Data dictionary – file that contains
metadata
▫ Consulted when data is read or modified
• Should perform the following functions:
▫ Should identify types of data division like
data item, segment, record & data base file
▫ Should give a unique name to each data
item type, record type, file type, database
& other data subdivision
▫ Should specify proper data types
▫ Should specify how record types are related
to make structures
▫ May define the type of encoding the program
uses in data items like binary, string etc.
▫ May define length of data items
▫ May define the range of values that a data
item can assume
▫ Specify means of checking errors in data
▫ Specify privacy locks
DML
• Language that enables users to access or
manipulate data
• Data manipulations refers to:
▫ Retrieval of information stored in database
▫ Insertion of new information into db
▫ Deletion of information from db
▫ Modification of data stored in db
Types of DML
• Procedural DML
▫ Require a user to specify what data is
needed and how to get it
• Non-procedural DML
▫ Require a user to specify what data is
needed without specifying how to get it
SQL processing
• Concept of data types
▫ Data must be distinguished from one
another
▫ Assigns each field a data type which
specifies the kind of value the field will
contain
Class Data type Description
ANSI
Text SQL Data
CHAR types
Values of this type must be
enclosed in single quotes
Exact Numeric DECIMAL Represent a fractional number
such as 15.45. Size argument
has two parts- precision and
scale. (5,2)
NUMERIC Same as decimal except digits
cannot exceed the precision
INTEGER Number without a decimal
point
SMALLINT Same as integer but size may
or may not be smaller than
integer
Approximate FLOAT represents a floating point
numeric number
REAL same as float except that no
size argument is used

You might also like