Unit 2 DBMS Class 12 Computer Science
Unit 2 DBMS Class 12 Computer Science
1
Unit 2 – DBMS
3. Complexity of Programming:
4. Poor Portability:
2. Network Model
This is an extension of the Hierarchical model. In this model data is organized more like a graph, and
are allowed to have more than one parent node.
In this database model data is more related as more relationships are established in this database
model.
Also, as the data is more related, hence accessing the data is also easier and fast.
This database model was used to map many-to-many data relationships.
This was the most widely used database model, before Relational Model was introduced.
3. Relational Model
In this model, data is organized in two-dimensional tables and the relationship is maintained by
storing a common field.
This model was introduced by E.F Codd in 1970, and since then it has been the most widely used
database model, infact, we can say the only database model used around the world.
The basic structure of data in the relational model is tables.
2
Unit 2 – DBMS
All the information related to a particular type is stored in rows of that table.
Hence, tables are also known as relations in relational model.
4. ER Model
ER Model stands for Entity Relationship Model is a high-level conceptual data model diagram.
ER model helps to systematically analyze data requirements to produce a well-designed database.
The ER Model represents real-world entities and the relationships between them.
Entities
o A real-world thing either living or non-living that is easily recognizable and non recognizable.
o It is anything in the enterprise that is to be represented in our database.
o It may be a physical thing or simply a fact about the enterprise or an event that happens in the
real world.
Examples of entities:
▪ Person: Employee, Student, Patient
▪ Place: Store, Building
▪ Object: Machine, product, and Car
▪ Event: Sale, Registration, Renewal
▪ Concept: Account, Course
Attributes
▪ It is a single-valued property of either an entity-type or a relationship-type.
▪ For example, a lecture might have attributes: time, date, duration, place, etc.
▪ An attribute in ER Diagram examples, is represented by an Ellipse
4
Unit 2 – DBMS
Centralized Database
A centralized database is basically a type of database that is stored, located as well as maintained at
a single location only.
This type of database is modified and managed from that location itself.
The centralized location is accessed via an internet connection (LAN, WAN, etc).
This centralized database is mainly used by institutions or organizations.
5
Unit 2 – DBMS
Advantages –
Since all data is stored at a single location only thus it is easier to access and co-ordinate data.
The centralized database has very minimal data redundancy since all data is stored at a single
place.
It is cheaper in comparison to all other databases available.
Disadvantages –
The data traffic in case of centralized database is more.
If any kind of system failure occurs at centralized system then entire data will be destroyed.
Distributed Database :
A distributed database is basically a type of database which consists of multiple databases that
are connected with each other and are spread across different physical locations.
The data that is stored on various physical locations can thus be managed independently of other
physical locations.
The communication between databases at different physical locations is thus done by a
computer network.
Advantages –
This database can be easily expanded as data is already spread across different physical
locations.
The distributed database can easily be accessed from different networks.
This database is more secure in comparison to centralized database.
Disadvantages –
This database is very costly and it is difficult to maintain because of its complexity.
In this database, it is difficult to provide a uniform view to user since it is spread across different
physical locations.
6
Unit 2 – DBMS
Database Normalization
Database Normalization is a technique of organizing the data in the database.
Normalization is a systematic approach of decomposing tables to eliminate data
redundancy(repetition) and undesirable characteristics like Insertion, Update and Deletion
Anomalies.
It is a multi-step process that puts data into tabular form, removing duplicated data from the
relation tables.
Normalization is used for mainly two purposes,
Eliminating redundant(useless) data.
Ensuring data dependencies make sense i.e data is logically stored.
Problems Without Normalization
7
Unit 2 – DBMS
Updation Anomaly
What if Mr. X leaves the college? or is no longer the HOD of computer science department?
In that case all the student records will have to be updated, and if by mistake we miss any record,
it will lead to data inconsistency.
This is Updation anomaly.
Deletion Anomaly
In our Student table, two different information's are kept together, Student information and
Branch information.
Hence, at the end of the academic year, if student records are deleted, we will also lose the
branch information.
This is Deletion anomaly.
Normalization rules
Normalization rules are divided into the following normal forms:
o First Normal Form
o Second Normal Form
o Third Normal Form
8
Unit 2 – DBMS
What is Dependency?
In this table, student_id is the primary key and will be unique for every row, hence we can
use student_id to fetch any row of data from this table
Even for a case, where student names are same, if we know the student_id we can easily fetch
the correct record.
In the above table all non prime attribute depends on prime attribute.
This is Dependency and we also call it Functional Dependency.
9
Unit 2 – DBMS
Let's create another table for Subject, which will have subject_id and subject_name fields
and subject_id will be the primary key.
Now we have a Student table with student information and another table Subject for storing
subject information.
Let's create another table Score, to store the marks obtained by students in the respective
subjects.
We will also be saving name of the teacher who teaches that subject along with marks.
In the score table we are saving the student_id to know which student's marks are these
and subject_id to know for which subject the marks are for.
Together, student_id + subject_id forms a Candidate Key for this table, which can be the Primary
key.
See, if I ask you to get me marks of student with student_id 10, can you get it from this table?
No, because you don't know for which subject.
And if I give you subject_id, you would not know for which student.
Hence we need student_id + subject_id to uniquely identify any row.
But where is Partial Dependency?
10
Unit 2 – DBMS
Now if you look at the Score table, we have a column names teacher which is only dependent on
the subject, for Java it's Java Teacher and for C++ it's C++ Teacher & so on.
Now as we just discussed that the primary key for this table is a composition of two columns
which is student_id & subject_id but the teacher's name only depends on subject, hence
the subject_id, and has nothing to do with student_id.
This is Partial Dependency, where an attribute in a table depends on only a part of the primary
key and not on the whole key.
How to remove Partial Dependency?
The simplest solution is to remove columns teacher from Score table and add it to the Subject
table. Hence, the Subject table will become:
And our Score table is now in the second normal form, with no partial dependency.
11
Unit 2 – DBMS
o Firewalls
o Establishment of user privileges
o Complicated by use of distributed systems such as internet access and client/ server
technology.
3. Managing Data Integrity
o Integrity controls protects data from unauthorized use
o Data consistency
o Maintaining data relationship
o Domains- sets allowable values
o Assertions- enforce database conditions
4. Data backup
o We must assume that a database will eventually fail
o Establishment procedures
▪ how often should the data be back-up?
▪ what data should be backed up more frequently?
▪ Who is responsible for the back ups?
5. Tuning database performance
o Set installation parameters/ upgrade DBMS
o Monitor memory and CPU usage
SQL
o SQL stands for Structured Query Language
o SQL lets you access and manipulate databases
o SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the
International Organization for Standardization (ISO) in 1987
o SQL can execute queries against a database
o SQL can retrieve data from a database
o SQL can insert records in a database
o SQL can update records in a database
o SQL can delete records from a database
o SQL can create new databases
o SQL can create new tables in a database
12