Professional Documents
Culture Documents
Unit 1
Unit 1
Unit 1
This model lacks data There is partial data This model provides data
independence. independence in this model. independence.
It is used to access the data It is used to access the data It is used to access the data
which is complex and which is complex and which is complex and
asymmetric. symmetric. symmetric.
VAX-DBMS, DMS-1100
of UNIVAC and
&XML and XAML use this SUPRADBMS’s use this It is mostly used in real world
model. model. applications. Oracle, SQL.
Logical: This level comprises the information that is actually stored in the
database in the form of tables. It also stores the relationship among the data
entities in relatively simple structures. At this level, the information available
to the user at the view level is unknown.
We can store the various attributes of an employee and relationships, e.g.
with the manager can also be stored.
View: This is the highest level of abstraction. Only a part of the actual
database is viewed by the users. This level exists to ease the accessibility of
the database by an individual user. Users view data in the form of rows and
columns. Tables and relations are used to store data. Multiple views of the
same database may exist. Users can just view the data and interact with the
database, storage and implementation details are hidden from them.
3. System Analyst :
System Analyst is a user who analyzes the requirements of
parametric end users. They check whether all the requirements of
end users are satisfied.
4. Sophisticated Users :
Sophisticated users can be engineers, scientists, business analyst,
who are familiar with the database. They can develop their own
data base applications according to their requirement. They don’t
write the program code but they interact the data base by writing
SQL queries directly through the query processor.
5. Data Base Designers :
Data Base Designers are the users who design the structure of
data base which includes tables, indexes, views, constraints,
triggers, stored procedures. He/she controls what data must be
stored and how the data items to be related.
6. Application Program :
Application Program are the back end programmers who writes the
code for the application programs.They are the computer
professionals. These programs could be written in Programming
languages such as Visual Basic, Developer, C, FORTRAN, COBOL
etc.
8. Simple:
Data base management system (DBMS) gives simple and clear
logical view of data. Many operations like insertion, deletion or
creation of file or data are easy to implement.
Disadvantages of DBMS
There are many advantages and disadvantages of DBMS (Database
Management System). The disadvantages of DBMS are explained below.
1. Increased Cost:
These are different types of costs:
1. Cost of Hardware and Software –
This is the first disadvantage of the database management system.
This is because, for DBMS, it is mandatory to have a high-speed
processor and also a large memory size. After all, nowadays there
is a large amount of data in every field which needs to be store
safely and with security.
The requirement of this large amount of space and a high-speed
processor needs expensive hardware and expensive software too.
That is, there is a requirement for sophisticated hardware and
software which means that we need to upgrade the hardware which
is used for the file-based system. Hardware and Software, both
require maintenance which costs very high. All the operating,
Training (all levels including programming, application
development, and database administration), licensing, and
regulatory compliance costs very high.
Introduction of ER Model
ER Model is used to model the logical view of the system from data
perspective which consists of these components:
Entity, Entity Type, Entity Set –
An Entity may be an object with a physical existence – a particular person,
car, house, or employee – or it may be an object with a conceptual existence
– a company, a job, or a university course.
An Entity is an object of Entity Type and set of all entities is called as entity
set. e.g.; E1 is an entity having Entity Type Student and set of all students is
called Entity Set. In ER diagram, Entity Type is represented as:
Attribute(s):
Attributes are the properties which define the entity type. For example,
Roll_No, Name, DOB, Age, Address, Mobile_No are the attributes which
defines entity type Student. In ER diagram, attribute is represented by an
oval.
1. Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called
key attribute.For example, Roll_No will be unique for each student. In ER
diagram, key attribute is represented by an oval with underlying lines.
2. Composite Attribute –
An attribute composed of many other attribute is called as composite
attribute. For example, Address attribute of student Entity type consists of
Street, City, State, and Country. In ER diagram, composite attribute is
represented by an oval comprising of ovals.
3. Multivalued Attribute –
An attribute consisting more than one value for a given entity. For example,
Phone_No (can be more than one for a given student). In ER diagram,
multivalued attribute is represented by double oval.
4. Derived Attribute –
An attribute which can be derived from other attributes of the entity type is
known as derived attribute. e.g.; Age (can be derived from DOB). In ER
diagram, derived attribute is represented by dashed oval.
The complete entity type Student with its attributes can be represented as:
Relationship Type and Relationship Set:
A relationship type represents the association between entity types. For
example,‘Enrolled in’ is a relationship type that exists between entity type
Student and Course. In ER diagram, relationship type is represented by a
diamond and connecting the entities with lines.
2. Binary Relationship –
When there are TWO entities set participating in a relation, the
relationship is called as binary relationship. For example, Student is enrolled
in Course.
3. n-ary Relationship –
When there are n entities set participating in a relation, the relationship is
called as n-ary relationship.
Cardinality:
The number of times an entity of an entity set participates in a
relationship set is known as cardinality. Cardinality can be of different
types:
1. One to one – When each entity in each entity set can take part only once
in the relationship, the cardinality is one to one. Let us assume that a male
can marry to one female and a female can marry to one male. So the
relationship will be one to one.
2. Many to one – When entities in one entity set can take part only once in
the relationship set and entities in other entity set can take part more
than once in the relationship set, cardinality is many to one. Let us
assume that a student can take only one course but one course can be taken
by many students. So the cardinality will be n to 1. It means that for one
course there can be n students but for one student, there will be only one
course.
Using Sets, it can be represented as:
In this case, each student is taking only 1 course but 1 course has been
taken by many students.
3. Many to many – When entities in all entity sets can take part more than
once in the relationship cardinality is many to many. Let us assume that a
student can take more than one course and one course can be taken by
many students. So the relationship will be many to many.
Mapping Constraints
o A mapping constraint is a data constraint that expresses the number of entities to
which another entity can be related via a relationship set.
o It is most useful in describing the relationship sets that involve more than two entity
sets.
o For binary relationship set R on an entity set A and B, there are four possible mapping
cardinalities. These are as follows:
1. One to one (1:1)
2. One to many (1:M)
3. Many to one (M:1)
4. Many to many (M:M)
One-to-one
In one-to-one mapping, an entity in E1 is associated with at most one entity in E2, and
an entity in E2 is associated with at most one entity in E1.
One-to-many
In one-to-many mapping, an entity in E1 is associated with any number of entities in
E2, and an entity in E2 is associated with at most one entity in E1.
Many-to-one
In one-to-many mapping, an entity in E1 is associated with at most one entity in E2,
and an entity in E2 is associated with any number of entities in E1.
Many-to-many
In many-to-many mapping, an entity in E1 is associated with any number of entities in
E2, and an entity in E2 is associated with any number of entities in E1.
Keys
o Keys play an important role in the relational database.
o It is used to uniquely identify any record or row of data from the table. It is also used
to establish and identify relationships between tables.
For example: In Student table, ID is used as a key because it is unique for each student.
In PERSON table, passport_number, license_number, SSN are keys since they are
unique for each person.
Types of key:
1. Primary key
o It is the first key which is used to identify one and only one instance of an entity
uniquely. An entity can contain multiple keys as we saw in PERSON table. The key which
is most suitable from those lists become a primary key.
o In the EMPLOYEE table, ID can be primary key since it is unique for each employee. In
the EMPLOYEE table, we can even select License_Number and Passport_Number as
primary key since they are also unique.
o For each entity, selection of the primary key is based on requirement and developers.
2. Candidate key
o A candidate key is an attribute or set of an attribute which can uniquely identify a tuple.
o The remaining attributes except for primary key are considered as a candidate key. The
candidate keys are as strong as the primary key.
For example: In the EMPLOYEE table, id is best suited for the primary key. Rest of the
attributes like SSN, Passport_Number, and License_Number, etc. are considered as a
candidate key.
3. Super Key
Super key is a set of an attribute which can uniquely identify a tuple. Super key is a
superset of a candidate key.
4. Foreign key
o Foreign keys are the column of the table which is used to point to the primary key of
another table.
o In a company, every employee works in a specific department, and employee and
department are two different entities. So we can't store the information of the
department in the employee table. That's why we link these two tables through the
primary key of one table.
o We add the primary key of the DEPARTMENT table, Department_Id as a new attribute
in the EMPLOYEE table.
o Now in the EMPLOYEE table, Department_Id is the foreign key, and both the tables are
related.
ER Diagram of a Company
ER Diagram is known as Entity-Relationship Diagram, it is used to analyze to
structure of the Database. It shows relationships between entities and their
attributes. An ER Model provides a means of communication.
ER diagram of Company has the following description :
•Company has several departments.
•Each department may have several Location.
• Departments are identified by a name, D_no, Location.
• A Manager control a particular department.
• Each department is associated with number of projects.
• Employees are identified by name, id, address, dob, dat
e_of_joining.
• An employee works in only one department but can work on several
project.
• We also keep track of number of hours worked by an employee on
a single project.
• Each employee has dependent
• Dependent has D_name, Gender and relationship.
ER Diagram of Company :
This Company ER diagram illustrates key information about Company,
including entities such as employee, department, project and dependent. It
allows to understand the relationships between entities.
Entities and their Attributes are
• Employee Entity : Attributes of Employee Entity are Name, Id,
Address, Gender, Dob and Doj.
Id is Primary Key for Employee Entity.
• Department Entity : Attributes of Department Entity are D_no,
Name and Location.
D_no is Primary Key for Department Entity.
• Project Entity : Attributes of Project Entity are P_No, Name and
Location.
P_No is Primary Key for Project Entity.
• Dependent Entity : Attributes of Dependent Entity are D_no,
Gender and relationship.
Relationships are :
• Employees works in Departments –
Many employee works in one Department but one employee can
not work in many departments.
• Manager controls a Department –
employee works under the manager of the Department and the
manager records the date of joining of employee in the department.
• Department has many Projects –
One department has many projects but one project can not come
under many departments.
• Employee works on project –
One employee works on several projects and the number of hours
worked by the employee on a single project is recorded.
• Employee has dependents –
Each Employee has dependents. Each dependent is dependent of
only one employee.
Enhanced ER Model
Today the complexity of the data is increasing so it becomes more and more
difficult to use the traditional ER model for database modeling. To reduce this
complexity of modeling we have to make improvements or enhancements were
made to the existing ER model to make it able to handle the complex application
in a better way.
Enhanced entity-relationship diagrams are advanced database diagrams very
similar to regular ER diagrams which represent requirements and complexities
of complex databases.
It is a diagrammatic technique for displaying the Sub Class and Super Class;
Specialization and Generalization; Union or Category; Aggregation etc.
Generalization and Specialization –
These are very common relationships found in real entities. However, this kind of
relationship was added later as an enhanced extension to the classical ER
model. Specialized classes are often called subclass while a generalized class is
called a superclass, probably inspired by object-oriented programming. A sub-
class is best understood by “IS-A analysis”. Following statements hopefully
makes some sense to your mind “Technician IS-A Employee”, “Laptop IS-A
Computer”.
An entity is a specialized type/class of another entity. For example, a Technician
is a special Employee in a university system Faculty is a special class of
Employee. We call this phenomenon generalization/specialization. In the
example here Employee is a generalized entity class while the Technician and
Faculty are specialized classes of Employee.
You might see some confusion in Sub-class and UNION; consider an example in
above figure Vehicle is super-class of CAR and Truck; this is very much the
correct example of the subclass as well but here use it differently we are saying
RTO Registered vehicle is UNION of Car and Vehicle, they do not inherit any
attribute of Vehicle, attributes of car and truck are altogether independent set,
where is in sub-classing situation car and truck would be inheriting the attribute
of vehicle class.
Specialization –
In specialization, an entity is divided into sub-entities based on their
characteristics. It is a top-down approach where higher level entity is
specialized into two or more lower level entities. For Example, EMPLOYEE
entity in an Employee management system can be specialized into
DEVELOPER, TESTER etc. as shown in Figure 2. In this case, common
attributes like E_NAME, E_SAL etc. become part of higher entity
(EMPLOYEE) and specialized attributes like TES_TYPE become part of
specialized entity (TESTER).
Aggregation –
An ER diagram is not capable of representing relationship between an entity
and a relationship which may be required in some scenarios. In those cases,
a relationship with its corresponding entities is aggregated into a higher level
entity. Aggregation is an abstraction through which we can represent
relationships as higher level entity sets.
For Example, Employee working for a project may require some machinery.
So, REQUIRE relationship is needed between relationship WORKS_FOR
and entity MACHINERY. Using aggregation, WORKS_FOR relationship with
its entities EMPLOYEE and PROJECT is aggregated into single entity and
relationship REQUIRE is created between aggregated entity and
MACHINERY.
Representing aggregation via schema –
To represent aggregation, create a schema containing:
1. primary key of the aggregated relationship
2. primary key of the associated entity set
3. descriptive attribute, if exists.