2. Data Model
• Data Model is the modeling of the data
description, data semantics, and consistency
constraints of the data.
• It provides the conceptual tools for describing
the design of a database at each level of data
abstraction.
• Therefore, there are following four data models
used for understanding the structure of the
database:
4. • 1) Relational Data Model: This type of model designs
the data in the form of rows and columns within a table.
• Thus, a relational model uses tables for representing
data and in-between relationships. Tables are also called
relations.
• This model was initially described by Edgar F. Codd, in
1969.
• The relational data model is the widely used model
which is primarily used by commercial data processing
applications.
6. • Entity-Relationship Data Model: An ER model is the logical
representation of data as objects and relationships among
them.
• These objects are known as entities, and relationship is an
association among these entities.
• This model was designed by Peter Chen and published in
1976 papers.
• It was widely used in database designing. A set of
attributes describe the entities.
• For example, student_name, student_id describes the
'student' entity.
• A set of the same type of entities is known as an 'Entity
set', and the set of the same type of relationships is known
as 'relationship set'.
8. • Object-based Data Model: An extension of
the ER model with notions of functions,
encapsulation, and object identity, as well.
• This model supports a rich type system that
includes structured and collection types.
• Thus, in 1980s, various database systems
following the object-oriented approach were
developed.
• Here, the objects are nothing but the data
carrying its properties.
9. • 4) Semistructured Data Model: This type of data model
is different from the other three data models
(explained above).
• The semistructured data model allows the data
specifications at places where the individual data items
of the same type may have different attributes sets.
• The Extensible Markup Language, also known as XML,
is widely used for representing the semistructured
data.
• Although XML was initially designed for including the
markup information to the text document, it gains
importance because of its application in the exchange
of data.
10. Data model Schema and Instance
• The data which is stored in the database at a
particular moment of time is called an instance of the
database.
• The overall design of a database is called schema.
• A database schema is the skeleton structure of the
database. It represents the logical view of the entire
database.
• A schema contains schema objects like table, foreign
key, primary key, views, columns, data types, stored
procedure, etc.
12. • A schema diagram can display only some
aspects of a schema like the name of record
type, data type, and constraints.
• Other aspects can't be specified through the
schema diagram.
• For example, the given figure neither show the
data type of each data item nor the
relationship among various files.
13. • A database schema can be represented by
using the visual diagram. That diagram shows
the database objects and relationship with
each other.
• A database schema is designed by the
database designers to help programmers
whose software will interact with the
database. The process of database creation is
called data modeling.
14. • In the database, actual data changes quite
frequently.
• For example, in the given figure, the database
changes whenever we add a new grade or add
a student.
• The data at a particular moment of time is
called the instance of the database.
15. • Data Independence
• Data independence can be explained using the
three-schema architecture.
• Data independence refers characteristic of
being able to modify the schema at one level
of the database system without altering the
schema at the next higher level.
16. • There are two types of data independence:
• 1. Logical Data Independence
• Logical data independence refers characteristic of being able
to change the conceptual schema without having to change
the external schema.
• Logical data independence is used to separate the external
level from the conceptual view.
• If we do any changes in the conceptual view of the data,
then the user view of the data would not be affected.
• Logical data independence occurs at the user interface level.
17. • Physical Data Independence
• Physical data independence can be defined as the
capacity to change the internal schema without
having to change the conceptual schema.
• If we do any changes in the storage size of the
database system server, then the Conceptual
structure of the database will not be affected.
• Physical data independence is used to separate
conceptual levels from the internal levels.
• Physical data independence occurs at the logical
interface level.
19. • Database Language
• A DBMS has appropriate languages and
interfaces to express database queries and
updates.
• Database languages can be used to read, store
and update the data in the database.
21. • Data Definition Language
• DDL stands for Data Definition Language. It is used to
define database structure or pattern.
• It is used to create schema, tables, indexes, constraints,
etc. in the database.
• Using the DDL statements, you can create the skeleton of
the database.
• Data definition language is used to store the information of
metadata like the number of tables and schemas, their
names, indexes, columns in each table, constraints, etc.
22. • Here are some tasks that come under DDL:
• Create: It is used to create objects in the database.
• Alter: It is used to alter the structure of the database.
• Drop: It is used to delete objects from the database.
• Truncate: It is used to remove all records from a table.
• Rename: It is used to rename an object.
• Comment: It is used to comment on the data dictionary.
23. • Data Manipulation Language
• DML stands for Data Manipulation Language.
It is used for accessing and manipulating data
in a database. It handles user requests.
• Here are some tasks that come under DML:
24. • Select: It is used to retrieve data from a database.
• Insert: It is used to insert data into a table.
• Update: It is used to update existing data within a table.
• Delete: It is used to delete all records from a table.
• Merge: It performs UPSERT operation, i.e., insert or
update operations.
• Call: It is used to call a structured query language or a Java
subprogram.
• Explain Plan: It has the parameter of explaining data.
• Lock Table: It controls concurrency.
25. • Data Control Language
• DCL stands for Data Control Language. It is
used to retrieve the stored or saved data.
• The DCL execution is transactional. It also has
rollback parameters.
• (But in Oracle database, the execution of data
control language does not have the feature of
rolling back.)
26. • Here are some tasks that come under DCL:
• Grant: It is used to give user access privileges to a
database.
• Revoke: It is used to take back permissions from
the user.
• There are the following operations which have
the authorization of Revoke:
• CONNECT, INSERT, USAGE, EXECUTE, DELETE,
UPDATE and SELECT.
27. • Transaction Control Language
• TCL is used to run the changes made by the DML
statement. TCL can be grouped into a logical transaction.
• Here are some tasks that come under TCL:
• Commit: It is used to save the transaction on the
database.
• Rollback: It is used to restore the database to original
since the last Commit.
29. ER-DIAGRAM
•
ER model
• ER model stands for an Entity-Relationship model. It is a
high-level data model. This model is used to define the
data elements and relationship for a specified system.
• It develops a conceptual design for the database. It also
develops a very simple and easy to design view of data.
• In ER modeling, the database structure is portrayed as a
diagram called an entity-relationship diagram.
30. • For example,
• Suppose we design a school database.
• In this database, the student will be an entity
with attributes like address, name, id, age, etc.
• The address can be another entity with
attributes like city, street name, pin code, etc
and there will be a relationship between
them.
35. • 1. Entity:
• An entity may be any object, class, person or
place. In the ER diagram, an entity can be
represented as rectangles.
• Consider an organization as an example-
manager, product, employee, department etc.
can be taken as an entity.
39. • An entity that depends on another entity
called a weak entity.
• The weak entity doesn't contain any key
attribute of its own.
• The weak entity is represented by a double
rectangle.
41. • 2. Attribute
• The attribute is used to describe the property
of an entity. Eclipse is used to represent an
attribute.
• For example, id, age, contact number, name,
etc. can be attributes of a student.
43. • a. Key Attribute
• The key attribute is used to represent the
main characteristics of an entity.
• It represents a primary key.
• The key attribute is represented by an ellipse
with the text underlined.
45. • . Composite Attribute
• An attribute that composed of many other
attributes is known as a composite attribute.
• The composite attribute is represented by an
ellipse, and those ellipses are connected with
an ellipse.
47. • An attribute can have more than one value.
These attributes are known as a multivalued
attribute. The double oval is used to represent
multivalued attribute.
• For example, a student can have more than
one phone number.
49. • d. Derived Attribute
• An attribute that can be derived from other
attribute is known as a derived attribute. It can
be represented by a dashed ellipse.
• For example, A person's age changes over
time and can be derived from another
attribute like Date of birth.
50. • 3. Relationship
• A relationship is used to describe the relation
between entities. Diamond or rhombus is
used to represent the relationship.
52. • b. One-to-many relationship
• When only one instance of the entity on the
left, and more than one instance of an entity on
the right associates with the relationship then
this is known as a one-to-many relationship.
• For example, Scientist can invent many
inventions, but the invention is done by the
only specific scientist.