2. CONCEPT OF DATABASE
Data :
It is a raw(unprocessed) facts which are composed of alphabets,
digits and other symbols may or may not give any sense.
Example- 2,RAM,KATHMANDU.
Information:
When data is processed using a database program or software, they
are converted into meaningful result, called information.
Example-
Sno :101
Name: RAM
Address :Kathmandu.
3. • Database:
It is a collection of interrelated data of a certain place or person or things
which is stored in computer in such a way that it can be easily accessed by
user. Data are stored generally in the tabular format in database.
• Flat File system/File processing :
It is a traditional way of storing data electronically.
Limitation of flat file processing systems:
o The same data was store in more than one file.
o Difficulty in representing data from users view.
o Time consuming and expensive.
o Data security is one of the major problems of FFPS.
o It is difficult for processing complex queries.
4. DATABASE MANAGEMENT
SYSTEM(DBMS)
• A DBMS is system software for creating and manage database.
•The DBMS provides users and programmers with a systematic
way to create, retrieve, update and manage data.
• EX : FoxPro, Dbase, Sybase, MS Access, My SQL, MS SQL
Server, Oracle, DB2 etc
5. MAJOR DATABASE ACTIVITIES ARE:
• Adding new file to the database.
• Inserting data into the database file.
• Retrieving/Viewing data from database.
• Updating data in existing database file.
• Deleting data from the database file.
• Removing files from the database.
6. ADVANTAGES OF DBMS
• Improved data sharing – end users have better access to more and better
managed data.
• Reduced data redundancy – same data may be duplicated at many
times or places called data redundancy .DBMS reduces duplication of Data.
• Data backup and recovery-provide facilities for recovering from
hardware and software failures.
• Inconsistency avoided: when the same data is duplicated and changes are
made at one site, and not other sites, it causes data consistency.
• Better Data integration – accuracy, consistency and up to date.
• Improved Data security – Unauthorized person cannot access data from
database.
• Multiple user interface - variety of interface for various user so that
users interact easily with database.
7. DISADVANTAGE OF DBMS
• Increased installation and management cost :
Database software is very expensive for large computer
systems. It also requires overhead costs for maintaining and
integrity functions.
• Requirement of new and specialized manpower : Because
of rapid changes in database technology and organization’s
business needs to maintain specialized skilled manpower.
• NeedsTechnicalTraining – it is complex to understand and
implement, so proper training is required to work properly.
• Complexity of Backup and Recovery – new storage space
are needed to hold data.
8. STRUCTURE QUERY LANGUAGE (SQL)
• It is an international standard database query language for
accessing and managing data in database.
• Sql was developed by IBM in early 1970s.
• Sql is used to control relational database.
• Sql is not programming language it is only used for
communicating with database.
9. SQL STATEMENTS
1. DDL (Data Definition Language):
DDL is used by the database designers and programmers to
specify the content and structure of the DATABASE.
The common DDL Commands are:
• Create – Used to generate a new table.
• Drop – Removes the table from database.
• Alter – Alter or Changes table structure.
• Rename- Rename the existing table.
11. 2. DML(DATA MANIPULATION LANGUAGE) :
DML is the language that allows an end user to manipulate the
data in the database.
Commands of DML
• Select : Select data from table.
• Insert : Insert data into the table.
• Update : Update existing data within a table.
• Delete : Delete records from table.
Example:
Select Name from student;
Insert into studentValues(101,'ram');
12. 3. DCL (DATA CONTROL LANGUAGE)
DCL includes commands for controlling data and access to the databases.
Commands of DCL
• Commit
• Rollback
• Grant etc
Example:
Grant create table to username;
Revoke create table from username;
13. DATABASE MODEL
• A database model shows the logical structure of a database,
including the relationships and constraints that determine how
data can be stored and accessed.
• Different types of database model
1. Hierarchical database model
2. Network database model.
3. Relational database model.
4. Entity-relationship model.
5. Object-oriented database model.
14. 1. HIERARCHICAL DATABASE MODEL
• The hierarchical model organizes data into a inverted tree-like
structure.
• All records in the hierarchical are called nodes. Each node is
related to the others node in a parent-child relationship in
order of one to many relationship.
• Each records has multiple fields/attributes.
15. Advantages
• It is the easiest model.
• It has one or more attributes.
• The searching is fast and easy, if parent is known.
• It supports one-to-one and one-to-many relationship.
Disadvantages
• It is old fashioned, outdated database model.
• It does not support many-to-many relationship.
• The dependency on parent node is not beneficial always.
• It increases redundancy because same data to be repeated in
different places.
16. 2. NETWORKS DATABASE MODEL
• A network database model consists of collection of records which are
inter-related to each other with the help of relationship.
• It replaced Hierarchical database model.
• Each records has multiple fields and each field has only one data value.
• Data elements can have many to many relationships.
17. Advantages :
• It accepts many-to-many relationship, so it is more flexible.
• The searching is faster because of multidirectional
pointers.
• It reduces redundancy because data shouldn’t be repeated
if same data is needed.
Disadvantages :
• It is one of the complex database models.
• It needs larger programs to handle the relationships.
• There is less security because of sharing data.
• It increases the processing overhead due to the complex
relationship.
18. 3. RELATIONAL DATABASE MODEL
• The database system which stores and display data in tabular format of rows
and columns is known RDBMS.
• These tables are known as relation.
• Relational model is most widely used model.
• Ex: Oracle, SQL, MS-Access, My SQL etc
19. Table: Student
Roll Name
1 Hari
2 Sita
3 Ram
Table: Subject
Roll Math English Computer
1 80 75 88
2 95 92 75
3 90 58 95
Table : Details
Roll Name Math English Computer
1 Hari 80 75 88
2 Sita 90 92 75
3 Ram 90 58 95
After relating Student and subject table
Relational Database Model
20. Advantages
• The breaking of complex database table into simple database table becomes
possible.
• Database processing is faster than other model.
• There is very less redundancy(repetition of data).
• The integrity rules can easily be implemented.
Disadvantages
• It is more complex than other models.
• There are too many rules because of complex relationship.
• It needs more powerful computers and data storage devices.
21. 4. OBJECT –ORIENTED MODEL
• An object database or object-oriented database is a database
management system in which information is represented in
the form of objects as used in object-oriented programming.
• We can store audios, pictures, videos, and other types of data
in databases, which was previously impossible with the
relational approach .
• Generally recommended when there is a business need for
high performance processing on complex data.
22. Advantages
Inheritance promotes data integrity.
Semantic content is added.
Disadvantages:
It is a complex navigational system.
High system overhead slows transactions.
23. ENTITY RELATIONSHIP MODEL
The diagrammatic representation of entities, attributes and
relationship is called E-R diagram.
COMPONENTS OF ER DIAGRAM:
1. ENTITY: An entity is a thing or object in the real word that distinct
from other objects. It has value and properties.
STUDENT
24. 2 . Attribute:
Attribute are properties possessed by on entity or relationship.
EX: STU_NO ,STU_NAME ,STU_SUB ETC.
3. Relationship:
A relationship is an association among several entities
and represents meaningful dependencies between
them.
EX:
ROLL_NO
TEACH
25. 4. Links:
The flow of information is indicated by the links in ER
Diagram. It is a connector of entities, attributes and
relationship.
Represented as:
30. Database elements
➢Tables – composed of records ( datasheets).
➢ Field – column in a table (Subject, roll no, Marks)
➢ Record – (Math,1001, 85)
➢ File - its stores data, information ,setting or commands.
➢ Keys – Set of an attributes that helps you to identify a row
and column in a table.
31. KEYS -
• A key in DBMS is an attribute or a set of attributes that help to uniquely
identify a tuple (or row) in a relation (or table).
Types of Keys:
1) Candidate key
2) Primary key
3) Alternate key
4) Foreign key
5) Composite key
32. 1. Candidate Key:
A candidate key is an attribute or set of attributes in a relation that are eligible
to become a primary key.
2. Primary Key:
The primary key refers to a column or a set of columns of a table that
helps us identify all the records uniquely present in that table.
It does not permit duplicate or null values.
3. Foreign key:
Foreign Key is used to establish relationships between two tables.
Foreign key is a attribute whose value is derived from the primary key of another
table.
4. Unique Key :
Unique Key is a column or set of columns that uniquely identify each record in a
table. A unique Key differs from a primary key because it can have only one null
value, whereas a primary Key cannot have any null values.
35. 5. Composite Key:
It is a combination of two or more columns in a table that can be used to
uniquely identify each row in the table .
when the columns are combined uniqueness is guaranteed, but when it
taken individually it does not guarantee uniqueness.
36. CONCEPT OF NORMALIZATION
• Normalization is the process of organizing data in a database.
• Normalization is a process of decomposing a big table into many smaller tables
to reduce redundancies and made data model more flexible.
• It is also used to eliminate undesirable characteristics like Insertion, Update, and
Deletion Anomalies.
Benefits of Normalization:
• The dependency between the data fields is identified.
• The redundancy in database is minimized.
• Data model is made more flexible and easier to maintain.
• It improves faster sorting and index creation.
• It improves the performance of the database system.
• It simplifies the structures of tables.
• It avoids the loss of information.
37. TYPES OF NORMALIZATION
• First Normal Form (1NF)
• Second Normal Form (2NF)
• Third Normal Form (3NF)
• Fourth Normal Form (4NF)
• Five Normal Form (5NF)
38. FIRST NORMAL FORM (1NF)
• A relation will be 1NF if it contains an atomic value.
• It states that an attribute of a table cannot hold multiple values. It must hold only single-valued
attribute.
• Example:
The decomposition of the EMPLOYEE table into 1NF has been shown below:
Roll_no Name Address Book_code Book_name
1 Anil Sunar Kathmandu B101 Physiscs
2 Arpita Mishra Biratnagar C101 Chemistry
3 Sajana Rai Pokhara CS101 Computer
Roll_no Fname Lname Address Book_code Book_name
1 Anil Sunar Kathmandu P101 Physiscs
2 Arpita Mishra Biratnagar C101 Chemistry
3 Sajana Rai Pokhara CS101 Computer
Details:
39. SECOND NORMAL FORM (2NF)
• It should be in First Normal Form.
• It identifies data dependencies.
• Non key attribute are functionally depends on key attribute(Primary Key).
Roll_no Fname Lname Address Book_code
1 Anil Sunar Kathmandu P101
2 Arpita Mishra Biratnagar C102
3 Sajana Rai Pokhara CS103
Book_code Book_name
P101 Physiscs
C102 Chemistry
CS103 Computer
Student_Details:
Book_Details:
40. 3NF(THIRD NORMAL FORM)
• It should be in the second normal form.
• It removes transitive dependencies in a table.
• I.E : if A, B, C is in relation R and A->B, B->C, then we can drive A->C using
functional dependency.
Roll_no Fname Lname Book_code
1 Anil Sunar P101
2 Arpita Mishra C102
3 Sajana Rai CS103
Fname Lname Address
Anil Sunar Kathmandu
Arpita Mishra Biratnagar
Sajana Rai Pokhara
41. DATABASE ARCHITECTURE
1. Centralized Database:
• A centralized database is stored at a single location such as a mainframe
computer.
• It is maintained and modified from that location only and usually accessed using
an internet connection such as a LAN or WAN. The centralized database is
used by organizations such as colleges, companies, banks etc.
42. 2. Distributed Database system:
▪ A distributed database is a database in which data is stored across
different physical locations. It may be stored in multiple computers
located in the same physical location or maybe dispersed over a network
of interconnected computers.
43. Centralized database system
• Centralized database system is
simple type.
• They are located on particular
location
• It consists of only one server.
• It is only suitable for small
organization and small scale
business.
• There is less chance of data lost.
• Maintenance is easy and security is
high.
Distributed Database system
• Distributed database is complex
type.
• They are located in many
geographical locations.
• It contains servers in several
locations.
• It is suitable for large organization.
• More chances of data hacking , theft
and lost.
• Maintenance is not easy and security
is low as compare to centralized
database system.
44. • Failure of server makes the
whole system down.
• There is no feature of load
balancing.
• Data Traffic rate is high.
• Cost of centralized database
system is low.
• Failure of one server does not
make the whole system down.
• There is feature of load
balancing.
• Data traffic rate is low.
• Cost of distributed database
system is high.
Centralized database system Distributed Database system
45. DATA SECURITY
• Data security is protection of data in database system against
unauthorized access, modification, failure, losses or destruction.
• Authorized access- only right people can access the right data.
• Destruction- fire, water, heat, dust, power failure, theft etc.
• To protect from physical damage we have (RAID-Redundant
array of in dependent disk) disk in each location.
46. SOME OF THE DATA SECURITY METHODS ARE:
• By using Proper backup in disks, tapes, CD etc. in order to prevent from
accidental loss.
• Making Physical prevention by using stabilizer and UPS to supply a regular
power.
• Using strong password protection system, making log in the system to prevent
data from unauthorized access to the database.
• By specifying the specific roles to every user of the database for grating the
appropriate permission to them.
• By keeping the system under lock or safe place.
• By implementing software protection like antivirus, firewalls, antispyware etc.
47. DATABASE RELATED TERMS
• Data dictionary:
It keeps all the information about the database system such as -
location, size of the database, tables, fields, user information, privileges,
backup system and recovery system etc.
It defines the data types for data fields.
It ensures the consistency in database.
49. DATA INTEGRITY:
• Data integrity is the maintenance and the assurance of the accuracy and
consistency of data over its entire life-cycle.
• Data integrity is important step in database designing and decision making.
• It ensures that the data should be accurate and consistent as it is the basic element
of database to -
➢ provide information at right time.
➢ to take right decision
➢ to make right planning for future.
50. DRAWBACKS IF DATA INTEGRITY IS NOT
MAINTAINED
• The unrelated data may be stored in the master and child table.
• The improper data may be stored in the column.
• The data may not come from a defined domain.
Ex: age –‘employee’ table having 500 as data values
• The change made in one table may not bring the necessary
changes in other table.
‘Sold quantity’ of an item is inserted in ‘sales’ table, then the
‘Stock quantity’ in ‘stock’ table remain constant.
51. DATA INTEGRITY CONSTRAINTS
• Data integrity is preserved by using types of
constraints(rules) called data integrity constraints.
• Types of constraints are:
1. Domain Integrity Constraints
2. Entity Integrity Constraints
3. Referential Integrity Constraints.
52. 1. Domain Integrity Constraints:
• It defines a set range of data values for given specific data field.
• It also determines whether null values are allowed or not in data fields.
2. Entity Integrity Constraints:
• It specifies all rows in table have a unique identifier, known as primary key(never be
null).
• When we change Primary key value in Master table, related key value in child table
will automatically changed.
53. 3. Referential Integrity Constraints:
• It ensures that the relationship between the primary
keys in the master table and foreign key in child
table are always maintained.
• It ensures that all foreign key values in a database
are valid and they are referenced by the primary
key.