SlideShare a Scribd company logo
1 of 50
A Programme Under the compumitra Series
Computer Database Basics
THEORY SESSION
“It is possible to store the mind with a million facts and still be
entirely uneducated.”
Steps to enlightenment
The facts and figures (DATA) forms the
base that leads to generation of
INFORMATION.
Knowing the techniques to apply
INFORMATION is KNOWLEDGE.
Perfect Understanding of KNOWLEDGE
along with a will to transfer and share it
for its best use is ENLIGHTENMENT. This
is rarely achieved but reaching closer to
this goal can still be an objective.
For E.g. A Reading of 98.6 Deg F Temperature is DATA. More than 98.6 is Fever
Condition is INFORMATION. Knowing the Ways to treat Fever Condition is
KNOWLEDGE. Knowing all reasons for fever and willingness to share this for benefit of
all is reaching closer to ENLIGHTENMENT. Few Enlightened people have changed this
world. But Remember that the Basis of enlightenment process was an accurately
taken DATA. This highlights the need for accurately recorded and timely available
DATA.
DATABASES ARE USED EVERYWHERE
OUTLINE
Database Creation Objectives
Database Management Systems
Database Types
Database Contents
Interaction with Databases
Relationship
Normalisation
Transactions
Security
Database Creation Objectives?
The decisions are mostly based on
'DATA' hence it is extremely
important to build an effective
system of recording and retrieving
data. Effectiveness always implies
Efficiency, Economy and
Exactness.
Primary Objectives
The term 'Database' which is often used in
context of organised digital storage of content
where the organisation of storage is done for
fast retrieval that can also facilitate ordering
and conditional grouping to make it
meaningful. So the primary objective with
which Databases are created are –
Speedy Retrieval (ways and means of storage
so that the pointers to data are set to reach
them quickly)
Ordering (Sorting on the basis of text, number,
date etc.)
Conditional Grouping (Getting the similar
items together based on certain predefined
match conditions)
Advanced Objectives
Security (Restricted and controlled
Access).
Safety and Integrity (Accuracy and
correctness)
Standardisation (Maintaining control
over the variety of data items).
Sharing Control (To allow independent
knowledge systems to exchange
information)
Surplus Control (Avoiding redundancy)
Database Management Systems (DBMS)
What is a DBMS
It is a Computer Based Software System that can cover all aspects
on data items such as –
 Definition of Entities
 Storage System Architectures.
 Access Security.
 Backup/restore capability.
 Configuration facility.
 Programmability.
 Entity Relationships.
 User Level Interfacing.
 Communication and Interchange Facilities.
 Multiple Usage Priortisation/Conflict Management.
RDBMS – Relational Database Management Systems
Most Database Systems Today are RDBMS.
A fully featured RDBMS is expected to follow codd's
rules(13 Rules numbered 0-12).
It is difficult to build a perfect RDBMS, but most
practical implementations are quite usable, provided
they are correctly structured.
RDBMS has a prime feature of avoiding data
duplication and hence maintaining the integrity of
data while transactions.
RDBMS also support an interaction language which is
called SQL (Structured Query Language)
Plain Non Relational Examples: Dbase, Clipper, Foxpro Old Versions.
Relational Examples: Access, SQL Server, Oracle, Ingres, DB2, MySQL etc.
Codd's Rules
0. System Must Use Relational Facilities.
1. Information Representation uniquely in rows in columns only.
2. Every value should be accessible.
3. Null values should be handled.
4. Database structure should be accessible.
5. Should support an access language with definition, manipulation and transaction support.
6.Views (Combination of Columns) should be updatable.
7.Insert,Update and Delete Should be supported at higher level of set of columns and rows.
8. Physical Data change should not require application to change.
9. Logical Data (organised in tables) should be independent of application code.
10. Constraints related to integrity should be separately storable.
11. Storage of Data Portions should be possible at separate places, without affecting application.
12. Bypassing of relational security should not be possible by an application even if it is available
at a lower level.
Edgar Frank Ted Codd
ODBMS – Object Data Management Systems
This is a recent advancement where Object
Oriented Programming concepts are integrated
into database.
For example a table row is an instance of set of
attributes defined as columns.
A related table may be treated as another object of
master table.
It also allows atrributes level hierarchy for e.g.
Address class may contain properties such as
building number, area, Locality, CityID, Pin etc.
ODBMS finds applications in telecommunication
databases, molecular biology and specialised
financial services.
OQL (Object Query Language) has been defined to
access this kind of database.
Some Notable Examples Include – db4, JADE,
PostGreSQL, Oracle (These have some ODBMS
functionality)
Databases Types
Types Classification Basis
Nature of Usage
 Operational
 Warehouse
 Analytical
Type of Processing
 Single Processor
 Distributed
Type of Storage File
 Flat File
 ISAM
 Heaps
 B+ Trees
Type of Content Expanse
 Legacy Database
 Hypermedia Database
Classification: Nature of Usage
Operational: Contains Detailed Data of
operations of any organisation, activity
or project. This is where transactions
occur directly.
Data Warehouse: This is historical data
archives of data which was earlier an
operational database. It is created for
the purpose of analysis.
Analytical: The analysis of data may be
done on a Data Warehouse or on
extracted data from an operational or
Data ware house date.
Classification: Type of Processing
Single Processor: Databases where entire set
of data items are available on one physical
system.
Distributed: In this case the data items are
available on multiple physical systems
connected through network. Still the access
to database is done in a way as if it is
logically one database. For e.g. A Multi-
Branch Office can have databases at all
branches that can be accessed using a
common software system.
DBMS like Oracle, SQL Azure allow multi-
system implementation of databases. This is
also called Databases on the Cloud or
Databases that support cloud computing.
Classification: Type of Storage File
Flat File: Text Files, Storage Like Comma
Separated Files fall into this category.
ISAM File: Indexed Sequential Access
Method allows data into fixed length fields
with separate Index files that contain
pointers.
Heap: It is a tree based data structure
where values towards the root are higher.
Heap Allows Dynamic allocation.
B+Tree: Efficient Retrieval, Insertion is
possible into this system. Records are
identified by keys that are organised as
multilevel indexes. RDBMS often
implement this kind of storage.
Classification: Types of Content Expanse
Legacy Database: The standard system
of database that allow storage of text,
numbers etc. fall into this category.
Hypermedia Database: The database
that contain hyperlinked content can
be viewed as hypermedia database.
For e.g. the Internet can be viewed as
a hypermedia database.
Database Contents
Main Data Content: Tables
Table is the most basic element in all
databases. It generally contains data
about a real world entity such as plant,
account, employee, class etc.
Table is a grid of columns and rows. One
can make a large number of tables in a
database (This limit is related to a
particular database type).
Atrributes of this entity are usually
defined as Columns (also called fields). For
e.g. plant can have and atrribute PlantID,
PlaneName and MaxAge)
A row or record is indicate multiple
instances of set of attribute values for the
given entity.
Plant
PlantID
PlantName
MaxAge
Entity
Attribute
(Columns)Rows
Table: Field/Columns Definition
While designing tables you will have to specify Column/field Name, Data Type and
Data Size.
Column name should describe the data item with crisp easily identifiable name. This
can not be repeated in a single table.
Data Type specifies which type of data that should be store in the particular field.
Maximum Care is Required to Select Data Types for optimum performance.
eg. Int – Non Decimal Numeric value.
string- Text Value.
Date - Date Value.
Defining Data Types helps to order the tables quickly.
Data Size specifies the field capacity (such as fixed 50 characters for a string field or
variable length of 50 Characters as per need of data item).
One may also need to specify whether a column can contain blank/null values or not.
Sometimes other properties like default value, possible value set, sort order basis,
description of field etc. may also be defined along with column definitions.
Data Types : MS ACCESS
DataTypes Stores Space Taken
Text combinations of text and numbers Max 255 chars
Memo lengthy text and numbers (May have
limited formatting functionality).
Max 65536 Characters
Date/Time date and time together 8 bytes
Number Stores integers or decimal numbers 1,2,4, or 8 bytes
Currency currency values 8 bytes
AutoNumber unique sequential (incrementing by 1) 4 bytes
Yes/No Yes/No, True/False, On/Off 1 bit
OLE Object for OLE objects like word file, excel sheet,
pictures etc.
Max 1 gigabyte
Hyperlink URL Max. 64,000 characters
Data Types : MS SQL SERVER
DataTypes Stores Space Taken
Tinyint, smallint, int, bigint An integer 1, 2, 4, or 8 Bytes
Decimal [precision,[scale]],
Numeric [p,s], float[n], real
Exact or Approximate Numerical
Values.
5-17 bytes or 8 bytes for
float and 4 bytes for real.
Smallmoney, money For currency 4, 8 bytes
Smalldatetime, Datetime Date and Time 4, 8 bytes
Char(n),Varchar(n), Varchar(max)
nchar(n),nVarchar(n),nVarchar(m
ax)
For Fixed or Variable Length Text
(The type Text is now outdated)
n prefix to these types support
uni-code data for multilingual
entry support.
0-8000 bytes or 0-2GB
Binary, VarBinary(n),
VarBinary(max)
Binary Data Stream (Type Image
is less preferred now)
0-8000 or 0-2GB data
Bit 0 or 1 1 bit
XML XML Data Content 0-2GB
Sql_variant Inconsistent or unspecified data
type
Max. 8016 vytes
Above list is based on SQL-Server 2005. Few less used data-types not shown here.
Other Content Elements in a Database
Indexes: Logical Instructions to view information in a certain
order.
Relationships: Instructions that indicate how entities are
dependent on each other.
Views. Preset selection of columns from multiple Tables
Programming Code: Often called stored procedures, that act
on certain events called Triggers.
Other rules related to access permissions, backups and data
interchange etc.
All above is usually stored as single physical file, which is
.mdb for MS-ACCESS or .mdf for MS-SQL.
Interaction with Databases.
Database Interaction Methods
Lower Level Direct Interaction is done using
SQL (Structured Query Language) as highlighted before.
Universal Database Connectivity is achieved by using the
ODBC (Open Database Connectivity) which provides APIs
and middle tier driver to be connected to most common
databases or even the files like excel files, csv etc.
Higher Level Connectivity is implemented with the use of
Forms. Some databases like MS-ACCESS provide the facility
of Forms as a integrated part of DBMS. For most other
RDBMS Forms are implemented as external programs.
Another form of Interaction can be pre-stored Queries
usually made using SQL within or outside the database. The
term 'query' means to search, to question, or to find. When
you query a database, you search for information in the
database.
Forms
We use forms to collect data from users .
Programmers use many controls like
Textbox, RadioButton, Checkboxes,
Dropdown List etc to collect information.
When user submit all the required
information is validated at the client end
itself. Few things that require server values
for comparison may be validated later at
the server side.
After client side validation the data is sent
to the server end for processing.
During the processing stage required SQL is
generated for Database interaction.
After Processing the results as desired by the
application requirement are sent to the
client side.
Text Box
Check Box
Radio Button
Multiline TextBox
Button
Relationship
Let's Revisit Entities for Relationship
Entities are real world abstract terms
for which we can define various
characteristics and we can observe
multiple instances on them. For e.g.
Employees, Books, Accounts,
Departments, Designations, Products
etc. Entities are usually defined as
tables in a database.
Attributes are characteristics or
properties associated with entities.
Relationship is association between
entities on the basis of certain
attributes.
In this example Employee is related to
Department on the basis of
DepartmentID
Employee
ID
Name
Age
DepartmentI
D
Department
ID
Name
HeadedBy
RELATIONSHIP
Types of Relationship
One-One Relationship - For each attribute in one table there
is at most one associated attribute in the other table.
One-Many Relationship - One attribute in table A is
associated with zero or more attributes in table B, but each
attribute in table B is associated with at most one attribute in
table A.
Many-Many Relationship - There are no restrictions on how
many attributes in either table are associated with an attribute in
the other.
MANAGER Manages DEPARTMENT
1 1
DEPARTMENT Has EMPLOYEE1 N
STUDENT Joins COURSE
N N
Relationship among tables
We can create relationship by the use of Primary
Key and Foreign key.
A Primary Key (PK) is a table column (attribute)
or combination of columns that uniquely
identifies a row in a table. Very often an ID is
provided for this purpose. This may however be
things like name/email combination.
Primary Key should not change over time and it
can not be NULL.
Table containing the primary key is often called
the master table in the given context.
A Foreign Key (FK) is a column or combination
of columns that matches the primary key column
of related table.
Unlike Primary Key, a foreign key value may
find many occurrences in a table.
ItemId
Item_name
Unit
Rate
ItemMaster
InvoiceID
Date
ItemId
Quantity
Sales
Primary Key
Foreign Key
Normalisation
Normalisation is all about avoiding
inconsistencies of possibilities of
duplication, mismatch or inability to
record something.
Normalisation Objectives
Increasing query efficiency by avoiding duplicity or
redundancy.
Ensuring integrity so that different values can not
be physically posted where only one value is
permitted.
Avoiding database re-design for change of data
contents.
Minimisation of database size by optimising the
field space usage.
Normalisation-Reducing Duplicity
ItemID ItemName SaleQty Date
001 Pencil 12 12-Aug-10
001 Pencil 9 13-Aug-10
002 Pen 5 13-Aug-10
ItemID ItemName
001 Pencil
002 Pen
ItemID SaleQty Date
001 12 12-Aug-10
001 9 13-Aug-10
002 5 13-Aug-10
An obvious better design to reduce duplicity of writing pencil
again and again is as follows.
Consider the table entry as below.
Normalisation-Ensuring Integrity
ItemID ItemName SaleQty Date
001 Pencil 12 12-Aug-10
001 Lead Pencil 9 13-Aug-10
002 Pen 5 13-Aug-10
ItemID ItemName
001 Pencil
002 Pen
ItemID SaleQty Date
001 12 12-Aug-10
001 9 13-Aug-10
002 5 13-Aug-10
Here the code '001' refers to 'Pencil' or 'Lead Pencil' . One code can only refer to one
particular name. Description change can obviously be misleading. Creating this
anamoly is however possible by a simple editing action in a table. Fighting creation of
such anomalies is also the goal of naormalisation. So the better approach is still as
follows.
Consider the table entry of the previous example once again.
Normalisation-Avoiding Redesign
BookID BookName Author1 Author2
001 Database
Systems
Codd Boyce
002 SQL Kevin Daniel
BookID BookName
001 Database
Systems
002 SQL
BookID Author
001 Codd
001 Boyce
002 Kevin
002 Daniel
Here if more than two authors of a new book are required to be entered an
additional Author 3, Author 4 fields etc. would be required. So the better design
choice is. This will make possible the addition of any number of authors without
database redesigning.
Consider the table entry as below.
Normalisation-Space Minimisation
BookID BookName Author1 Author2
001 Database
Systems
Codd Boyce
002 SQL Kevin
BookID BookName
001 Database
Systems
002 SQL
BookID Author
001 Codd
001 Boyce
002 Kevin
Here if only one author if a book is there then the space for Author2 is likely to be
wasted. Following design choice shows the obvious advantage.
Consider the table entry similar to previous example again.
In ALL these examples the improvement we did is called normalisation.
Normal Forms
Normal Forms are a way to depict level of
normalisation for a specific purpose.
Edgar F.Codd (father of RDBMS) initially
established three Normal Forms: 1NF, 2NF
and 3NF.
Other normal forms called 4NF, 5NF 6NF,
BCNF (Boyce-Codd Normal Form),
DKNF(Domain-Key Normal Form).
Normalisation is not an progressive activity
from 1NF to 6NF. Well designed tables may
be in 3NF in first go itself and are also like to
meet the criteria for 4NF or 5NF.
6NF definition is as recent as defined in 2002.
First Normal Form (1NF)
EmpID Name DeptID DeptName skill1 skill2 skill3
1 Ramesh 201 R&D C Perl Java
Repeating columns within a row
No repeating columns
within a row
To meet criteria of 1NF Each attribute must be atomic
 Repeating columns are not allowed within a row.
 There should not be any multi valued columns.
Remember we have seen a similar Book-Author example earlier.
Example 1:
Table: Employee (Unnormalised)
Table: Employee (1NF)
EmpID Name DeptID DeptName Skill
1 Ramesh 201 R&D C
1 Ramesh 201 R&D Perl
1 Ramesh 201 R&D Java
1NF (No multi valued columns.)
EmpID name DeptID DeptName Skill
1 Ramesh 201 R&D C, Perl, Java
Separating
records in
different rows
Example 2:
Table: Employee (Un-normalised)
Table: Employee (1NF)
EmpID Name DeptID DeptName Skill
1 Ramesh 201 R&D C
1 Ramesh 201 R&D Perl
1 Ramesh 201 R&D Java
Clearly just doing 1NF may generate lot of row level duplication. So, Lets
proceed to 2NF
Second Normal Form(2NF)
Each attribute must be functionally dependent on the primary key which uniquely
determines the value of attributes in the table. To achieve this non-dependent
attributes might have to be moved to other tables.
2NF improves data integrity by preventing update, insert, and delete anomalies.
EmpID Name DeptID DeptName Skill
1 Ramesh 201 R&D C
1 Ramesh 201 R&D Perl
1 Ramesh 201 R&D Java
2 Ashok 224 IT Linux
2 Ashok 224 IT Mac
Skill is not functionally
dependent on EmpID so
move to another table.
EmpID Name DeptID DeptName
1 Ramesh 201 R&D
2 Ashok 224 IT
EmpID Skill
1 C
1 Perl
1 Java
2 Linux
2 Mac
Table: Employee (Only 1NF Normalised)
Table: Employee (Normalised-2NF)
Table: Skill (Normalised-2NF)
Third Normal Form(3NF)
Visibly Separate Entities within a table given as attributes needs to be moved to
separate tables. This process is called removing transitive dependencies
3NF further improves data integrity.
EmpID EmpName DeptID DeptName
1 Ramesh 201 R&D
2 Ashok 224 IT
Department is clearly a separate
entity with its own attributes.
Although it has singular values for
each employee
EmpID Name DeptID
1 Ramesh 201
2 Ashok 224
DeptID DeptName
201 R&D
224 IT
Table: Employee (Only 2NF Normalised)
Table: Employee (Normalised-3NF) Table: Department(Normalised-3NF)
Student is advised to check examples of other normal forms
from internet or other references
43
Database Design
Design something means planning
the course of actions to be taken,
using some models. Database
designing is no different.
Database Designing Steps
Identify the Entities in your database. For e.g. a library
management database shall have entities like – Book,
Author, User, Supplier etc.
Try to create an Entity-Relationship Diagram which
also cover attributes of each entity and relationship
amongst entities.
Create physical database by creating tables and then
defining various attributes along with type, size and
other features of each attributes.
Build relationships as defined by the ER model.
Define user permissions and other security aspects.
Plan other things such as program portions to be fired
against certain database related events (Stored
Procedures)
Define maintenance policies, backup schedules etc.
45
Database Security
Database Security, although talked a
lot, is stillthe most ignored aspect of it.
Security Provisions in Modern Databases
Administrator level access to entire
RDBMS installation.
Separate User level access to each
Schema.
Table level ownership.
Prevention from accidental breakage
of integrity.
Record Level locking facilities.
Levels of Security in Database Systems
Access Control: Who will gain access
Authentication: The person who gain
access is authorised to perform what.
Auditing: Periodic checking to monitor
who has been doing what.
Encryption: Information encoding to
prevent unauthorised accessors to
actually do something.
Integrity: Techniques to prevent
accidental damage.
Meaning of security
Security is not safety alone.
 Safety is prevention from damage
 While Security is safety combined
with prevention from unauthorised
usage.
Unauthorised usage can lead to
 Delibrate/Accidental attack on
database content.
 Incorrect interpretation of content.
 Complete Denial of Service.
 Attempt to damage the operations
for other vested interests.
Bibliography
http://www.atlasindia.com/sql.htm
http://www.cdis-
now.com/uploads/media/WhyDoYouN
eedaDatabase.pdf
http://www.w3schools.com/sql/sql_data
types.asp
http://www.theonestopwebsiteshop.co
m/web-design/database-type.htm
www.odbms.org
Ask and guide me at
sunmitraeducation@gmail.com
Share this information with as many
people as possible.
Keep visiting www.sunmitra.com for
programme updates.

More Related Content

What's hot

6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
koolkampus
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1
ahfiki
 

What's hot (20)

Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Database language
Database languageDatabase language
Database language
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
Types of Database Models
Types of Database ModelsTypes of Database Models
Types of Database Models
 
Object Oriented Database Management System
Object Oriented Database Management SystemObject Oriented Database Management System
Object Oriented Database Management System
 
Characteristics and Advantages of Database Management System
Characteristics and Advantages of Database Management SystemCharacteristics and Advantages of Database Management System
Characteristics and Advantages of Database Management System
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approach
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
SQL commands
SQL commandsSQL commands
SQL commands
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Data models
Data modelsData models
Data models
 
Structured query language
Structured query languageStructured query language
Structured query language
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
 
RDBMS
RDBMSRDBMS
RDBMS
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1
 

Similar to Database Basics Theory

data base system to new data science lerne
data base system to new data science lernedata base system to new data science lerne
data base system to new data science lerne
tarunprajapati0t
 

Similar to Database Basics Theory (20)

Database management system
Database management systemDatabase management system
Database management system
 
Ch-1-Introduction-to-Database.pdf
Ch-1-Introduction-to-Database.pdfCh-1-Introduction-to-Database.pdf
Ch-1-Introduction-to-Database.pdf
 
DBMS PART 1.docx
DBMS PART 1.docxDBMS PART 1.docx
DBMS PART 1.docx
 
RDBMS to NoSQL. An overview.
RDBMS to NoSQL. An overview.RDBMS to NoSQL. An overview.
RDBMS to NoSQL. An overview.
 
data base system to new data science lerne
data base system to new data science lernedata base system to new data science lerne
data base system to new data science lerne
 
Database Management Systems
Database Management SystemsDatabase Management Systems
Database Management Systems
 
Database Management System, Lecture-1
Database Management System, Lecture-1Database Management System, Lecture-1
Database Management System, Lecture-1
 
27 fcs157al2
27 fcs157al227 fcs157al2
27 fcs157al2
 
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQLA STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
 
A Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQLA Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQL
 
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQLA STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
 
A Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQLA Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQL
 
DBMS - Introduction
DBMS - IntroductionDBMS - Introduction
DBMS - Introduction
 
TAMUC LO 8
TAMUC LO 8TAMUC LO 8
TAMUC LO 8
 
Database Management System Part-1.pptx
Database Management System Part-1.pptxDatabase Management System Part-1.pptx
Database Management System Part-1.pptx
 
Database fundamentals
Database fundamentalsDatabase fundamentals
Database fundamentals
 
Unit01 dbms
Unit01 dbmsUnit01 dbms
Unit01 dbms
 
DATABASE Lecture 1 and 2.pptx
DATABASE Lecture 1 and 2.pptxDATABASE Lecture 1 and 2.pptx
DATABASE Lecture 1 and 2.pptx
 
Database Concepts 101
Database Concepts 101Database Concepts 101
Database Concepts 101
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 

More from sunmitraeducation

More from sunmitraeducation (20)

Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Installing JDK and first java program
Installing JDK and first java programInstalling JDK and first java program
Installing JDK and first java program
 
Project1 VB
Project1 VBProject1 VB
Project1 VB
 
Project1 CS
Project1 CSProject1 CS
Project1 CS
 
Grid Vew Control VB
Grid Vew Control VBGrid Vew Control VB
Grid Vew Control VB
 
Grid View Control CS
Grid View Control CSGrid View Control CS
Grid View Control CS
 
Ms Access
Ms AccessMs Access
Ms Access
 
Visual Web Developer and Web Controls VB set 3
Visual Web Developer and Web Controls VB set 3Visual Web Developer and Web Controls VB set 3
Visual Web Developer and Web Controls VB set 3
 
Visual Web Developer and Web Controls CS set 3
Visual Web Developer and Web Controls CS set 3Visual Web Developer and Web Controls CS set 3
Visual Web Developer and Web Controls CS set 3
 
Progamming Primer Polymorphism (Method Overloading) VB
Progamming Primer Polymorphism (Method Overloading) VBProgamming Primer Polymorphism (Method Overloading) VB
Progamming Primer Polymorphism (Method Overloading) VB
 
Programming Primer EncapsulationVB
Programming Primer EncapsulationVBProgramming Primer EncapsulationVB
Programming Primer EncapsulationVB
 
Programming Primer Encapsulation CS
Programming Primer Encapsulation CSProgramming Primer Encapsulation CS
Programming Primer Encapsulation CS
 
Programming Primer Inheritance VB
Programming Primer Inheritance VBProgramming Primer Inheritance VB
Programming Primer Inheritance VB
 
Programming Primer Inheritance CS
Programming Primer Inheritance CSProgramming Primer Inheritance CS
Programming Primer Inheritance CS
 
ProgrammingPrimerAndOOPS
ProgrammingPrimerAndOOPSProgrammingPrimerAndOOPS
ProgrammingPrimerAndOOPS
 
Web Server Controls VB Set 1
Web Server Controls VB Set 1Web Server Controls VB Set 1
Web Server Controls VB Set 1
 
Web Server Controls CS Set
Web Server Controls CS Set Web Server Controls CS Set
Web Server Controls CS Set
 
Web Controls Set-1
Web Controls Set-1Web Controls Set-1
Web Controls Set-1
 
Understanding IDEs
Understanding IDEsUnderstanding IDEs
Understanding IDEs
 
Html Server Image Control VB
Html Server Image Control VBHtml Server Image Control VB
Html Server Image Control VB
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 

Database Basics Theory

  • 1. A Programme Under the compumitra Series Computer Database Basics THEORY SESSION “It is possible to store the mind with a million facts and still be entirely uneducated.”
  • 2. Steps to enlightenment The facts and figures (DATA) forms the base that leads to generation of INFORMATION. Knowing the techniques to apply INFORMATION is KNOWLEDGE. Perfect Understanding of KNOWLEDGE along with a will to transfer and share it for its best use is ENLIGHTENMENT. This is rarely achieved but reaching closer to this goal can still be an objective. For E.g. A Reading of 98.6 Deg F Temperature is DATA. More than 98.6 is Fever Condition is INFORMATION. Knowing the Ways to treat Fever Condition is KNOWLEDGE. Knowing all reasons for fever and willingness to share this for benefit of all is reaching closer to ENLIGHTENMENT. Few Enlightened people have changed this world. But Remember that the Basis of enlightenment process was an accurately taken DATA. This highlights the need for accurately recorded and timely available DATA.
  • 3. DATABASES ARE USED EVERYWHERE
  • 4. OUTLINE Database Creation Objectives Database Management Systems Database Types Database Contents Interaction with Databases Relationship Normalisation Transactions Security
  • 5. Database Creation Objectives? The decisions are mostly based on 'DATA' hence it is extremely important to build an effective system of recording and retrieving data. Effectiveness always implies Efficiency, Economy and Exactness.
  • 6. Primary Objectives The term 'Database' which is often used in context of organised digital storage of content where the organisation of storage is done for fast retrieval that can also facilitate ordering and conditional grouping to make it meaningful. So the primary objective with which Databases are created are – Speedy Retrieval (ways and means of storage so that the pointers to data are set to reach them quickly) Ordering (Sorting on the basis of text, number, date etc.) Conditional Grouping (Getting the similar items together based on certain predefined match conditions)
  • 7. Advanced Objectives Security (Restricted and controlled Access). Safety and Integrity (Accuracy and correctness) Standardisation (Maintaining control over the variety of data items). Sharing Control (To allow independent knowledge systems to exchange information) Surplus Control (Avoiding redundancy)
  • 9. What is a DBMS It is a Computer Based Software System that can cover all aspects on data items such as –  Definition of Entities  Storage System Architectures.  Access Security.  Backup/restore capability.  Configuration facility.  Programmability.  Entity Relationships.  User Level Interfacing.  Communication and Interchange Facilities.  Multiple Usage Priortisation/Conflict Management.
  • 10. RDBMS – Relational Database Management Systems Most Database Systems Today are RDBMS. A fully featured RDBMS is expected to follow codd's rules(13 Rules numbered 0-12). It is difficult to build a perfect RDBMS, but most practical implementations are quite usable, provided they are correctly structured. RDBMS has a prime feature of avoiding data duplication and hence maintaining the integrity of data while transactions. RDBMS also support an interaction language which is called SQL (Structured Query Language) Plain Non Relational Examples: Dbase, Clipper, Foxpro Old Versions. Relational Examples: Access, SQL Server, Oracle, Ingres, DB2, MySQL etc.
  • 11. Codd's Rules 0. System Must Use Relational Facilities. 1. Information Representation uniquely in rows in columns only. 2. Every value should be accessible. 3. Null values should be handled. 4. Database structure should be accessible. 5. Should support an access language with definition, manipulation and transaction support. 6.Views (Combination of Columns) should be updatable. 7.Insert,Update and Delete Should be supported at higher level of set of columns and rows. 8. Physical Data change should not require application to change. 9. Logical Data (organised in tables) should be independent of application code. 10. Constraints related to integrity should be separately storable. 11. Storage of Data Portions should be possible at separate places, without affecting application. 12. Bypassing of relational security should not be possible by an application even if it is available at a lower level. Edgar Frank Ted Codd
  • 12. ODBMS – Object Data Management Systems This is a recent advancement where Object Oriented Programming concepts are integrated into database. For example a table row is an instance of set of attributes defined as columns. A related table may be treated as another object of master table. It also allows atrributes level hierarchy for e.g. Address class may contain properties such as building number, area, Locality, CityID, Pin etc. ODBMS finds applications in telecommunication databases, molecular biology and specialised financial services. OQL (Object Query Language) has been defined to access this kind of database. Some Notable Examples Include – db4, JADE, PostGreSQL, Oracle (These have some ODBMS functionality)
  • 14. Types Classification Basis Nature of Usage  Operational  Warehouse  Analytical Type of Processing  Single Processor  Distributed Type of Storage File  Flat File  ISAM  Heaps  B+ Trees Type of Content Expanse  Legacy Database  Hypermedia Database
  • 15. Classification: Nature of Usage Operational: Contains Detailed Data of operations of any organisation, activity or project. This is where transactions occur directly. Data Warehouse: This is historical data archives of data which was earlier an operational database. It is created for the purpose of analysis. Analytical: The analysis of data may be done on a Data Warehouse or on extracted data from an operational or Data ware house date.
  • 16. Classification: Type of Processing Single Processor: Databases where entire set of data items are available on one physical system. Distributed: In this case the data items are available on multiple physical systems connected through network. Still the access to database is done in a way as if it is logically one database. For e.g. A Multi- Branch Office can have databases at all branches that can be accessed using a common software system. DBMS like Oracle, SQL Azure allow multi- system implementation of databases. This is also called Databases on the Cloud or Databases that support cloud computing.
  • 17. Classification: Type of Storage File Flat File: Text Files, Storage Like Comma Separated Files fall into this category. ISAM File: Indexed Sequential Access Method allows data into fixed length fields with separate Index files that contain pointers. Heap: It is a tree based data structure where values towards the root are higher. Heap Allows Dynamic allocation. B+Tree: Efficient Retrieval, Insertion is possible into this system. Records are identified by keys that are organised as multilevel indexes. RDBMS often implement this kind of storage.
  • 18. Classification: Types of Content Expanse Legacy Database: The standard system of database that allow storage of text, numbers etc. fall into this category. Hypermedia Database: The database that contain hyperlinked content can be viewed as hypermedia database. For e.g. the Internet can be viewed as a hypermedia database.
  • 20. Main Data Content: Tables Table is the most basic element in all databases. It generally contains data about a real world entity such as plant, account, employee, class etc. Table is a grid of columns and rows. One can make a large number of tables in a database (This limit is related to a particular database type). Atrributes of this entity are usually defined as Columns (also called fields). For e.g. plant can have and atrribute PlantID, PlaneName and MaxAge) A row or record is indicate multiple instances of set of attribute values for the given entity. Plant PlantID PlantName MaxAge Entity Attribute (Columns)Rows
  • 21. Table: Field/Columns Definition While designing tables you will have to specify Column/field Name, Data Type and Data Size. Column name should describe the data item with crisp easily identifiable name. This can not be repeated in a single table. Data Type specifies which type of data that should be store in the particular field. Maximum Care is Required to Select Data Types for optimum performance. eg. Int – Non Decimal Numeric value. string- Text Value. Date - Date Value. Defining Data Types helps to order the tables quickly. Data Size specifies the field capacity (such as fixed 50 characters for a string field or variable length of 50 Characters as per need of data item). One may also need to specify whether a column can contain blank/null values or not. Sometimes other properties like default value, possible value set, sort order basis, description of field etc. may also be defined along with column definitions.
  • 22. Data Types : MS ACCESS DataTypes Stores Space Taken Text combinations of text and numbers Max 255 chars Memo lengthy text and numbers (May have limited formatting functionality). Max 65536 Characters Date/Time date and time together 8 bytes Number Stores integers or decimal numbers 1,2,4, or 8 bytes Currency currency values 8 bytes AutoNumber unique sequential (incrementing by 1) 4 bytes Yes/No Yes/No, True/False, On/Off 1 bit OLE Object for OLE objects like word file, excel sheet, pictures etc. Max 1 gigabyte Hyperlink URL Max. 64,000 characters
  • 23. Data Types : MS SQL SERVER DataTypes Stores Space Taken Tinyint, smallint, int, bigint An integer 1, 2, 4, or 8 Bytes Decimal [precision,[scale]], Numeric [p,s], float[n], real Exact or Approximate Numerical Values. 5-17 bytes or 8 bytes for float and 4 bytes for real. Smallmoney, money For currency 4, 8 bytes Smalldatetime, Datetime Date and Time 4, 8 bytes Char(n),Varchar(n), Varchar(max) nchar(n),nVarchar(n),nVarchar(m ax) For Fixed or Variable Length Text (The type Text is now outdated) n prefix to these types support uni-code data for multilingual entry support. 0-8000 bytes or 0-2GB Binary, VarBinary(n), VarBinary(max) Binary Data Stream (Type Image is less preferred now) 0-8000 or 0-2GB data Bit 0 or 1 1 bit XML XML Data Content 0-2GB Sql_variant Inconsistent or unspecified data type Max. 8016 vytes Above list is based on SQL-Server 2005. Few less used data-types not shown here.
  • 24. Other Content Elements in a Database Indexes: Logical Instructions to view information in a certain order. Relationships: Instructions that indicate how entities are dependent on each other. Views. Preset selection of columns from multiple Tables Programming Code: Often called stored procedures, that act on certain events called Triggers. Other rules related to access permissions, backups and data interchange etc. All above is usually stored as single physical file, which is .mdb for MS-ACCESS or .mdf for MS-SQL.
  • 26. Database Interaction Methods Lower Level Direct Interaction is done using SQL (Structured Query Language) as highlighted before. Universal Database Connectivity is achieved by using the ODBC (Open Database Connectivity) which provides APIs and middle tier driver to be connected to most common databases or even the files like excel files, csv etc. Higher Level Connectivity is implemented with the use of Forms. Some databases like MS-ACCESS provide the facility of Forms as a integrated part of DBMS. For most other RDBMS Forms are implemented as external programs. Another form of Interaction can be pre-stored Queries usually made using SQL within or outside the database. The term 'query' means to search, to question, or to find. When you query a database, you search for information in the database.
  • 27. Forms We use forms to collect data from users . Programmers use many controls like Textbox, RadioButton, Checkboxes, Dropdown List etc to collect information. When user submit all the required information is validated at the client end itself. Few things that require server values for comparison may be validated later at the server side. After client side validation the data is sent to the server end for processing. During the processing stage required SQL is generated for Database interaction. After Processing the results as desired by the application requirement are sent to the client side. Text Box Check Box Radio Button Multiline TextBox Button
  • 29. Let's Revisit Entities for Relationship Entities are real world abstract terms for which we can define various characteristics and we can observe multiple instances on them. For e.g. Employees, Books, Accounts, Departments, Designations, Products etc. Entities are usually defined as tables in a database. Attributes are characteristics or properties associated with entities. Relationship is association between entities on the basis of certain attributes. In this example Employee is related to Department on the basis of DepartmentID Employee ID Name Age DepartmentI D Department ID Name HeadedBy RELATIONSHIP
  • 30. Types of Relationship One-One Relationship - For each attribute in one table there is at most one associated attribute in the other table. One-Many Relationship - One attribute in table A is associated with zero or more attributes in table B, but each attribute in table B is associated with at most one attribute in table A. Many-Many Relationship - There are no restrictions on how many attributes in either table are associated with an attribute in the other. MANAGER Manages DEPARTMENT 1 1 DEPARTMENT Has EMPLOYEE1 N STUDENT Joins COURSE N N
  • 31. Relationship among tables We can create relationship by the use of Primary Key and Foreign key. A Primary Key (PK) is a table column (attribute) or combination of columns that uniquely identifies a row in a table. Very often an ID is provided for this purpose. This may however be things like name/email combination. Primary Key should not change over time and it can not be NULL. Table containing the primary key is often called the master table in the given context. A Foreign Key (FK) is a column or combination of columns that matches the primary key column of related table. Unlike Primary Key, a foreign key value may find many occurrences in a table. ItemId Item_name Unit Rate ItemMaster InvoiceID Date ItemId Quantity Sales Primary Key Foreign Key
  • 32. Normalisation Normalisation is all about avoiding inconsistencies of possibilities of duplication, mismatch or inability to record something.
  • 33. Normalisation Objectives Increasing query efficiency by avoiding duplicity or redundancy. Ensuring integrity so that different values can not be physically posted where only one value is permitted. Avoiding database re-design for change of data contents. Minimisation of database size by optimising the field space usage.
  • 34. Normalisation-Reducing Duplicity ItemID ItemName SaleQty Date 001 Pencil 12 12-Aug-10 001 Pencil 9 13-Aug-10 002 Pen 5 13-Aug-10 ItemID ItemName 001 Pencil 002 Pen ItemID SaleQty Date 001 12 12-Aug-10 001 9 13-Aug-10 002 5 13-Aug-10 An obvious better design to reduce duplicity of writing pencil again and again is as follows. Consider the table entry as below.
  • 35. Normalisation-Ensuring Integrity ItemID ItemName SaleQty Date 001 Pencil 12 12-Aug-10 001 Lead Pencil 9 13-Aug-10 002 Pen 5 13-Aug-10 ItemID ItemName 001 Pencil 002 Pen ItemID SaleQty Date 001 12 12-Aug-10 001 9 13-Aug-10 002 5 13-Aug-10 Here the code '001' refers to 'Pencil' or 'Lead Pencil' . One code can only refer to one particular name. Description change can obviously be misleading. Creating this anamoly is however possible by a simple editing action in a table. Fighting creation of such anomalies is also the goal of naormalisation. So the better approach is still as follows. Consider the table entry of the previous example once again.
  • 36. Normalisation-Avoiding Redesign BookID BookName Author1 Author2 001 Database Systems Codd Boyce 002 SQL Kevin Daniel BookID BookName 001 Database Systems 002 SQL BookID Author 001 Codd 001 Boyce 002 Kevin 002 Daniel Here if more than two authors of a new book are required to be entered an additional Author 3, Author 4 fields etc. would be required. So the better design choice is. This will make possible the addition of any number of authors without database redesigning. Consider the table entry as below.
  • 37. Normalisation-Space Minimisation BookID BookName Author1 Author2 001 Database Systems Codd Boyce 002 SQL Kevin BookID BookName 001 Database Systems 002 SQL BookID Author 001 Codd 001 Boyce 002 Kevin Here if only one author if a book is there then the space for Author2 is likely to be wasted. Following design choice shows the obvious advantage. Consider the table entry similar to previous example again. In ALL these examples the improvement we did is called normalisation.
  • 38. Normal Forms Normal Forms are a way to depict level of normalisation for a specific purpose. Edgar F.Codd (father of RDBMS) initially established three Normal Forms: 1NF, 2NF and 3NF. Other normal forms called 4NF, 5NF 6NF, BCNF (Boyce-Codd Normal Form), DKNF(Domain-Key Normal Form). Normalisation is not an progressive activity from 1NF to 6NF. Well designed tables may be in 3NF in first go itself and are also like to meet the criteria for 4NF or 5NF. 6NF definition is as recent as defined in 2002.
  • 39. First Normal Form (1NF) EmpID Name DeptID DeptName skill1 skill2 skill3 1 Ramesh 201 R&D C Perl Java Repeating columns within a row No repeating columns within a row To meet criteria of 1NF Each attribute must be atomic  Repeating columns are not allowed within a row.  There should not be any multi valued columns. Remember we have seen a similar Book-Author example earlier. Example 1: Table: Employee (Unnormalised) Table: Employee (1NF) EmpID Name DeptID DeptName Skill 1 Ramesh 201 R&D C 1 Ramesh 201 R&D Perl 1 Ramesh 201 R&D Java
  • 40. 1NF (No multi valued columns.) EmpID name DeptID DeptName Skill 1 Ramesh 201 R&D C, Perl, Java Separating records in different rows Example 2: Table: Employee (Un-normalised) Table: Employee (1NF) EmpID Name DeptID DeptName Skill 1 Ramesh 201 R&D C 1 Ramesh 201 R&D Perl 1 Ramesh 201 R&D Java Clearly just doing 1NF may generate lot of row level duplication. So, Lets proceed to 2NF
  • 41. Second Normal Form(2NF) Each attribute must be functionally dependent on the primary key which uniquely determines the value of attributes in the table. To achieve this non-dependent attributes might have to be moved to other tables. 2NF improves data integrity by preventing update, insert, and delete anomalies. EmpID Name DeptID DeptName Skill 1 Ramesh 201 R&D C 1 Ramesh 201 R&D Perl 1 Ramesh 201 R&D Java 2 Ashok 224 IT Linux 2 Ashok 224 IT Mac Skill is not functionally dependent on EmpID so move to another table. EmpID Name DeptID DeptName 1 Ramesh 201 R&D 2 Ashok 224 IT EmpID Skill 1 C 1 Perl 1 Java 2 Linux 2 Mac Table: Employee (Only 1NF Normalised) Table: Employee (Normalised-2NF) Table: Skill (Normalised-2NF)
  • 42. Third Normal Form(3NF) Visibly Separate Entities within a table given as attributes needs to be moved to separate tables. This process is called removing transitive dependencies 3NF further improves data integrity. EmpID EmpName DeptID DeptName 1 Ramesh 201 R&D 2 Ashok 224 IT Department is clearly a separate entity with its own attributes. Although it has singular values for each employee EmpID Name DeptID 1 Ramesh 201 2 Ashok 224 DeptID DeptName 201 R&D 224 IT Table: Employee (Only 2NF Normalised) Table: Employee (Normalised-3NF) Table: Department(Normalised-3NF) Student is advised to check examples of other normal forms from internet or other references
  • 43. 43 Database Design Design something means planning the course of actions to be taken, using some models. Database designing is no different.
  • 44. Database Designing Steps Identify the Entities in your database. For e.g. a library management database shall have entities like – Book, Author, User, Supplier etc. Try to create an Entity-Relationship Diagram which also cover attributes of each entity and relationship amongst entities. Create physical database by creating tables and then defining various attributes along with type, size and other features of each attributes. Build relationships as defined by the ER model. Define user permissions and other security aspects. Plan other things such as program portions to be fired against certain database related events (Stored Procedures) Define maintenance policies, backup schedules etc.
  • 45. 45 Database Security Database Security, although talked a lot, is stillthe most ignored aspect of it.
  • 46. Security Provisions in Modern Databases Administrator level access to entire RDBMS installation. Separate User level access to each Schema. Table level ownership. Prevention from accidental breakage of integrity. Record Level locking facilities.
  • 47. Levels of Security in Database Systems Access Control: Who will gain access Authentication: The person who gain access is authorised to perform what. Auditing: Periodic checking to monitor who has been doing what. Encryption: Information encoding to prevent unauthorised accessors to actually do something. Integrity: Techniques to prevent accidental damage.
  • 48. Meaning of security Security is not safety alone.  Safety is prevention from damage  While Security is safety combined with prevention from unauthorised usage. Unauthorised usage can lead to  Delibrate/Accidental attack on database content.  Incorrect interpretation of content.  Complete Denial of Service.  Attempt to damage the operations for other vested interests.
  • 50. Ask and guide me at sunmitraeducation@gmail.com Share this information with as many people as possible. Keep visiting www.sunmitra.com for programme updates.