Chapter_two_note
Chapter_two_note
Data Models
It defines the data elements and the relationships between the data elements.
Data Models are used to show how data is stored, connected, accessed and
updated in the database management system. Here, we use a set of symbols and
text to represent the information so that members of the organization can
communicate and understand it. Though there are many data models being used
nowadays but the Relational model is the most widely used model.
1. Hierarchical Model:=>
Hierarchical Model was the first DBMS model. This model organizes the
data in the hierarchical tree structure. The hierarchy starts from the root
which has root data and then it expands in the form of a tree adding child
node to the parent node.
As more and more relationships need to be handled the system might get
complex. So, a user must be having detailed knowledge of the model to
work with the model.
Any change like updation, deletion, insertion is very complex.
4. Relational Model:=>
Relational Model is the most widely used model. In this model, the data is
maintained in the form of a two-dimensional table. All the information is stored in
the form of row and columns. The basic structure of a relational model is tables.
So, the tables are also called relations in the relational model. Example: In
Hardware Overheads: For hiding the complexities and making things easier
for the user this model requires more powerful hardware computers and
data storage devices.
Bad Design: As the relational model is very easy to design and use. So the
users don't need to know how the data is stored in order to access it. This
ease of design can lead to the development of a poor database which
would slow down if the database grows.
But all these disadvantages are minor as compared to the advantages of the
relational model. These problems can be avoided with the help of proper
implementation and organisation
The real-world problems are more closely represented through the object-
oriented data model. In this model, both the data and relationship are present in
a single structure known as an object. We can store audio, video, images, etc in
the database which was not possible in the relational model(although you can
store audio and video in relational database, it is adviced not to store in the
relational database). In this model, two are more objects are connected through
links. We use this link to relate one object to other objects . This can be
understood by the example given below:
In the above example, we have two objects Employee and Department. All the
data and relationships of each object are contained as a single unit. The attributes
like Name, Job_title of the employee and the methods which will be performed by
that object are stored as a single object. The two objects are connected through a
common attribute i.e the Department_id and the communication between these
two will be done with the help of this common id.
Entity type:=>
Entity type:=>
a. Strong entity type:=>Entity type having key attribute where key attribute
is a unique identifier of a particular row.
b. Weak entity type:=> Entity type does not have key attribute.
Example:=>
ERD attributes are characteristics of the entity that help users to better
understand the database. Attributes are included to include details of the various
entities that are highlighted in a conceptual ER diagram.
Example: Student has attributes like name, age, roll number, and many more. To
uniquely identify the student, we use the primary key as a roll number as it is not
repeated. Attributes can also be subdivided into another set of attributes.
Types of attributes :=>
a. Single attributes
b. Composite attributes
c. Single-valued attributes
d. Multi-valued attributes
e. Derived attribute
f. Complex attribute
a. Single attributes:=> An attribute that cannot be further subdivided into
components is a simple attribute.
Example: The roll number of a student, the id number of an employee.
b. Composite attribute:=>
An attribute that can be split into components is a composite attribute.
Example: The address can be further split into house number, street
number, city, state, country, and pin code, the name can also be split into
first name middle name, and last name.
c. Single-valued attribute:=>
The attribute which takes up only a single value for each entity instance is a
single-valued attribute.
Example:
The ‘Net Banking Active Bin’ attribute gives weather particular customer
having net banking facility activated or not activated.
For bank which does not offer facility of net banking in customer table ‘Net
Banking Active Bin’ attribute is always null till Net banking facility is not
activated as this attribute indicates Bank offers net banking facility or does
not offers.
g. Stored attribute:
The stored attribute are those attribute which doesn’t require any type of
further update since they are stored in the database.
h. Key attribute:
Key attributes are those attributes that can uniquely identify the entity in
the entity set.
Example: Roll-No is the key attribute because it can uniquely identify the
student.
Types of keys:=>
Key:=>
-> A key is a value which can always be 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:=> Id is used as a key in the student table because it is unique
for each student.
In the person table, passport_number, License_number are keys since they
are unique for each person.
Types of keys:=>
a. Super key
b. Candidate key
c. Primary key
d. Composite key
e. Foreign key
a. Super key:=>
A super key is a set of one or more attributes that, taken collectively,
allow us to identify uniquely an entity in the entity set.
For example:=> In the student table with attribute
(S_rollno, S_name, S_branch,S_year)
Super key=> S1 -> S_rollno, S_name
S2 -> S_rollno, S_branch
S3 -> S_rollno, S_year
S4 -> S_rollno, S_name, S_branch
S5 -> S_rollno, S-branch, S_year
b. Candidate key :=>
The minimal set of attributes that can uniquely a tuple is known as a
candidate key
Candidate key can be defined as the minimum number of super key
that identifies the record uniquely.
It must contain unique values
Every table must have at least a single candidate key.
For example:=> In student table with attribute (S_rollno,S_name,
S_branch, S_year)
Candidate key=> C1=> S_rollno
C2 => S_rollno, S_name
c. Primary key:=> It can be defined as the minimum number of
candidate key that is chosen by the database designer as the
principal means of identifying entities within an entity set. It is a
unique key. It can identify only one tuple (record) at a time. It has no
duplicate values , it has unique values. It cannot be NULL. Primary
keys are not necessarily to be a single column , more than one the
column can also be a primary key for a table.
For example :=> In student table with attribute(S_rollno, S_name,
S_branch, S_year)
Primary key => P1 => S-rollno
d. Composite key:=> Whenever a primary key consists of more than one
attribute , it is known as composite key,
For example, In student table with attribute: (S_rollno, S_id,
S_name,S_branch)
Composite key:=> S_rollno, S_id
e. Foreign key:=> A foreign key is a column whose value is the same as
the primary key of another table. It combines two or more (relations)
at a time. They act as a cross reference between the tables. Foreign
key are the column of the table used to point the primary key of
another table.
a. One-to-One Relationship:=>
The relationship that exist when each record of one table is
related to only one record of other table
Example:> One school has one principal.
b. One-to-many Relationship:=> A single entity in a table is
associated with multiple entities in another table, e.g., one
teacher can teach multiple classes.
c. Many-to-one Relationship:=> Multiple entities in a table are
associated with a single entity in another table, e.g., many
students can be enrolled in one course.
In the context of databases, relationship types refer to the various ways in which
entities in different tables can be associated with each other. The primary
relationship types include one-to-one, one-to-many, many-to-one, and many-to-
many relationships, which describe how the records in one table can relate to
records in another.
Sets in this context refer to the collections of entities or records that participate in
these relationships. Each set is a group of entities that can be linked through a
defined relationship type. For example, in a one-to-many relationship between
teachers and classes, one set consists of teachers, and the other set consists of
classes, with the relationship defining how each teacher (entity in the first set)
can be associated with multiple classes (entities in the second set).
-Lines, which links attributes to entity sets and entity set to relationship.
E r digarm of library mangement system
ER DIAGRAM OF restaurant
management system