Unit 1
Unit 1
Demerits:
5. It is old fashioned, outdated database model.
6. It does not support many-to-many relationship.
7. The dependency on parent node is not beneficial always.
8. It increases redundancy because same data is to be repeated in
different places.
ii. Network Database Model: The network model replaced hierarchical
model due to some limitation on the model. Suppose an employee relates
to two departments then the hierarchical model cannot able to arrange
records in proper place. So, network database model was emerged
(appear) to arrange non-hierarchical database. The structure of database is
more like graph rather than tree structure. The main limitation of this
model is less security.
Merits:
1. It accepts many-to-many relationship, so it is more flexible.
2. The searching is faster.
3. The network model is simple and easy to design.
4. It reduces redundancy.
Demerits:
5. It is difficult to handle the relationship in complex program.
6. There is less security because of sharing data.
7. It increases the processing overhead(tension) due to the complex
relationship.
Fig. Network Model
Demerits:
5. It is more complex than other models.
6. There are too many rules because of complex
relationships(tables).
7. It needs more powerful computers and data storage devices.
Fig. Relational Database model
Entity Relationship Model : The entity relationship model (ER model) is based on a
perception(opinion or view or observation) of a real world object or entity. The diagrammatic
representation of entities, attributes and their relationship is described by ER- diagram. The E-R
diagram is an overall logical structure of a database that can be expressed graphically.
1. Entity: An entity is a “thing” or “object” in the real world. For example , if student is an entity,
is identified by registration number. It is represented by rectangle.
student
2. Attribute: Attributes are properties possessed by an entity or relationship. For e.g. std_no,
std_name, std_sub are the attributes of the entity student. Attribute is represented by oval
or ellipse.
Roll no
Teach
4. Lines: The flow of information is indicated by the lines in ER-diagram. It is simply a line. It is a
connector of entities, attributes and relationship.
Example of ER-diagram:
Name ID Name
Address
Subject
Class Faculty
E.g.2.
To insert records into a table student
Syntax:
INSERT into table_name
VALUES(List of values);
E.g.
INSERT into student
VALUES(22,’RAM’);
E.g.3
To select data from table
Synatx:
SELECT field1, field2,………FROM table_name
E.g.
SELECT sid,name FROM student
i) Data Definition Language(DDL): DDL is used by the database
designers and programmers to specify the contents and structure of
the table. It includes created or deleted tables , link between tables
etc.
DDL statements are: CREATE TABLE, ALTER TABLE, DROP , RENAME
TABLE .
E.g.1.
To create a table
Syntax:
CREATE table_name(field1 data_type, field2 data_type,…….);
E.g.
CREATE student(sid number(4), name char(25));
ii) Data Manipulation Language(DML): DML is related with
manipulation of records such as retrieval , sorting, display and
deletion of records or data. It includes insert, delete and update.
E.g.2.
To insert records into a table student
Syntax:
INSERT into table_name
VALUES(List of values);
E.g.
INSERT into student
VALUES(22,’RAM’);
E.g.
CREATE DATABASE class12;
E.g.
Dropping(deleting) the database
Syntax:
DROP DATABASE database_name;
E.g.
DROP DATABASE class12;
Altering table( adding, deleting or modifying columns in an existing
table)
E.g. E.g.
Adding column Modifying column
Syntax: Syntax:
ALTER TABLE table_name ALTER TABLE table_name
ADD column_name datatype; MODIFY COLUMN column_name datatype;
E.g. E.g.
ALTER TABLE student ALTER TABLE student
ADD E-mail varchar(255); MODIFY COLUMN salary int;
E.g.
E.g.
Deleting column
Deleting table
Syntax:
Syntax:
ALTER TABLE table_name
DROP TABLE table_name;
DROP column_name datatype;
E.g.
E.g.
DROP TABLE student;
ALTER TABLE student
DROP E-mail varchar(255);
Some other SQL statement:
E.g.
Selecting data
Syntax:
SELECT column1,column2,…FROM table_name;
E.g.
SELECT * FROM student; (all column)
SELECT Roll,name FROM student; (only roll and name will be select)
E.g.
Deleting data
Syntax:
DELETE FROM table_name WHERE condition;
E.g.
DELETE FROM student WHERE name=‘Shyam’;
Q. What is normalization? Explain the types of normalization in brief.
Ans: Normalization:
Database normalization, or simply normalization, is the
process of organizing the columns (attributes) and tables (relations)
of a relational database to reduce data redundancy and improve
data integrity (accurate). It was first proposed by Dr. Edgar F. Codd,
as an integral part of a relational model. He had introduced few
rules for normalizing the database in 1970 A.D.
The types of normalization are as follows:
i. First Normal Form(1NF)
ii. Second Normal Form(2NF)
iii. Third Normal Form(3NF)
Table: Students
Name Roll no Class Sub1_Name Sub1_Marks Sub2_Name Sub2_Marks
Ram 1 XI computer 90 Account 95
Man 1 XII Computer 95 Account 93
Hari 2 XI computer 85 Account 85
Alok 2 XII computer 96 Account 94
Fig. 1NF
Table3: Marks
Name Sub-Name Sub-Marks
Ram Computer 90
Ram Account 95
Man Computer 95
Man Account 93
Hari Computer 85
Hari Account 85
Alok Computer 96
Alok Account 94
Fig. 2NF
iii)3NF: 3NF goes one large step further:
-It should be in the 2NF.
-It removes column that are not depend upon the primary key.
Table1:Student Table2:Subject
SID Name Roll CID SubID Sub_Name
1 Ram 1 11 C1 Computer
2 Man 1 12 A1 Account
3 Hari 2 11
Table4:Marks
4 Alok 2 12 Name Sub-Name Sub-Marks
Ram C1 90
Table3:Class Ram A1 95
CID Class Man C1 95
11 XI Man A1 93
12 XII Hari C1 85
Hari A1 85
Fig. 3NF Alok C1 96
Alok A1 94
Q. Why is normalization needed?
Ans: Normalization is needed because to reduce data redundancy, make
database more flexible and easier to maintain.
ii. They are located in particular location. ii. They are located in many geographical
location.
iii. It doesn’t contain server at several iii. It contain server at several location.
location.
iv. It is only suitable for small iv. It is suitable for large organization.
organization.
v. There is less chances of data loss. v. There is more chances of data hacking,
theft and lost.
2. Access Control:
The security mechanism of DBMS must include some provisions for
restricting access to the database by unauthorized users. Access control
is done by creating user accounts and to control login process by the
DBMS.
3. Encryption :
This method is used to protect sensitive data (such as credit card
numbers) OTP (One Time Password) numbers and other sensitive
numbers.
The Date/Time field allows storage of date and time information. The
Date/Time
date/time field now also includes the Auto Calendar feature.
The Currency data type stores values in a monetary format. This can be
Currency used with financial data as 8-byte numbers with precision to four decimal
places.
Yes/No Boolean data storage of true/false values.
The OLE Object field stores images, documents, graphs etc. from Office
OLE Object and Windows based programs. The maximum data size is 2 GB, although
this will slow down a database.
The Hyperlink field type is used to store web addresses. This has a
Hyperlink
maximum size limit of 1 GB of data.
The Attachment field type is used to store images, spreadsheet files,
documents, charts and other types of supported files to the records in
Attachment
your database. This is a new feature that has been introduced with
Microsoft Access 2007.
THANK YOU