Database_concept
Database_concept
What is a Database?
Examples of databases.
You can create a database for;
• Customers’ details.
• Personal records.
• Employees’ records.
• Library records.
• Flight schedules.
• A music collection.
• An Address book (or Telephone directory), where each person has the Name, Address, City
& Telephone no
• These are programs used to store & manage files or records containing related information.
• A collection of programs required to store & retrieve data from a database.
• A DBMS is a tool that allows one to create, maintain, update and store the data within a
database.
A DBMS is a complex software, which creates, expands & maintains the database, and it also
provides the interface between the user and the data in the database.
A DBMS enables the user to create lists of information in a computer, analyse them, add new
information, delete old information, and so on. It allows users to efficiently store information in
an orderly manner for quick retrieval.
A DBMS can also be used as a programming tool to write custom-made programs.
The DBMS is a set of software, which have several functions in relation to the database as listed
below:
1. Creates or constructs the database contents through the Data Manipulation Languages.
2. Interfaces (links) the user to the database contents through Data Manipulation Languages.
3. Ensures the growth of the database contents through addition of new fields & records onto
the database.
4. Maintains the contents of the database. This involves adding new records or files into the
database, modifying the already existing records & deleting of the outdated records.
5. It helps the user to sort through the records & compile lists based on any criteria he/she
would like to establish.
6. Manages the storage space for the data within the database & keeps track of all the data in
the database.
7. It provides flexible processing methods for the contents of the database.
8. Protects the contents of the database against all sorts of damage or misuse, e.g. illegal
access.
9. Monitors the usage of the database contents to determine the rarely used data and those
that are frequently used, so that they can be made readily available, whenever need arises.
10. It maintains a dictionary of the data within the database & manages the data descriptions in
the dictionary.
• Creation.
• Manipulation.
• Control, and
• Report generation.
Database systems can be used to store data, retrieve and generate reports.
Many parts are repaired by the vendors from whom they are purchased. A database is used
to maintain data on the parts that have been shipped to vendors and those that are
outstanding from the inventory. Data relating to the guarantees and warranties of
individual vendors are also stored in the database.
DISADVANTAGES OF DATABASES.
1. A Database system requires a big size, very high cost & a lot of time to implement.
2. A Database requires the use of a large-scale computer system.
3. The time involved. A project of this type requires a minimum of 1 – 2 years.
4. A large full-time staff is also required to design, program, & support the implementation of a
database.
5. The cost of the database project is a limiting factor for many organizations.
6. Database-oriented computer systems are not luxuries, and are undertaken when proven
economically reasonable.
Attributes can be used to describe both simple and complex entities. A product, for example, might
be described by a single attribute such as name or price. However, it can also be described by
multiple attributes such as name, price, and date of manufacture. In addition, some attributes
might be used to describe other attributes. For example, an attribute called "color" might describe
a product's color.
Attributes also play an important role in making databases searchable. For example, if we want to
find all customers who live in a particular zip code, we can use the customer's address attribute to
search for them. Or if we want to find all products that cost less than $10, we can use the
product's price attribute to search for them.
In short, attributes are important in DBMS because they help define the data structure in a
database. Without attributes, it would be difficult to organize and query data meaningfully.
Attributes also help to ensure data accuracy by providing clear definitions for the data being
entered into a database.
Types of Attributes
Let's understand the different types of attributes in DBMS, along with their examples.
2. Composite Attributes
Composite attributes are made up of two or more simple attributes. For example, a person's
address may be a composite attribute that is made up of the person's street address, city, state,
and zip code. Composite attributes can be used to create more complex data models and can be
helpful when trying to represent data in a concise way.
Single-valued attributes can only have one value. For example, a person's Social Security Number
is a single-valued attribute. Social Security Numbers are used to uniquely identify individuals in the
United States and are, therefore, single-valued attributes.
Examples of single-valued attributes include employee numbers, customer numbers, and product
codes. Single-valued attributes are typically used to provide a unique identifier for an entity and
are often used in databases.
4. Multivalued Attributes
Multivalued attributes can have more than one value. For example, a person may have multiple
email addresses or phone numbers. Multivalued attributes in DBMS are often used to store
information about relationships between entities. For instance, an employee entity might have a
multivalued attribute called "dependents" that stores the names of the employee's dependents.
Multivalued attributes can also be used to represent hierarchical data.
6. Complex Attributes
The complex attribute in DBMS involves both multivalued and composite attributes. For example,
someone might have more than one house, and each house might have more than one phone.
The phone is then considered a complex attribute.
7. Key Attributes
DBMS's key attributes are used to uniquely identify each row in a table. Usually, there is more than
one key attribute in a table (primary key and foreign key). For example: In a table of employees,
the employee ID would be the primary key, while the manager ID would be the foreign key.
8. Stored Attributes
By: Mr. Emmanuel Koroma
In a DBMS, stored attributes are the data that remain constant and fixed for an entity instance.
These values help in deriving the derived attributes. For example: consider a customer entity in a
bank. The customer's name, age, and address would be stored attributes. The customer's account
balance (a derived attribute) could be calculated based on the transactions (another stored
attribute) associated with the customer. So, these are the different attribute types in DBMS and
their importance. We believe, by now, you must be intrigued to learn more about the most wanted
database in the world. If yes, do consider a MongoDB Administrative Course keywords to get
access to 100+ courses and experience 24 hours of instructor training.
Attributes
Information such as property, facts you need to describe each table – Attributes are facts or
descriptions of entities. They are also often nouns and become the columns of the table. For
example, for entity students, the attributes can be first name, last name, email, address, and
phone numbers.
• Primary key is an attribute or a set of attributes that uniquely identifies an instance of the entity. For
example, for a student entity, student number is the primary key since no two students have the
same student number. We can have only one primary key in a table. It identifies uniquely every row
and it cannot be null.
• Foreign key is a key used to link two tables together. Typically, you take the primary key field from
one table and insert it into the other table where it becomes a foreign key (it remains a primary key
in the original table). We can have more than one foreign key in a table.
Relationships: How tables are linked together – Relationships are the associations between the
entities. Verbs often describe relationships between entities. We will use Crow’s Foot Symbols to
Cardinality: it defines the possible number of occurrences in one entity which is associated with
the number of occurrences in another. For example, ONE team has MANY players. When present
in an ERD, the entity Team and Player are inter-connected with a one-to-many relationship.
In an ER diagram, cardinality is represented as a crow’s foot at the connector’s ends. The three
common cardinal relationships are one-to-one, one-to-many, and many-to-many. Here is some
examples cardinality of relationship in ERD:
While all the three levels of an ER model contain entities with attributes and relationships, they
differ in the purposes they are created for and the audiences they are meant to target.
Conceptual ERD models the business objects that should exist in a system and the relationships
between them. A conceptual model is developed to present an overall picture of the system by
recognizing the business objects involved. It defines what entities exist, NOT which tables. For
example, ‘many to many’ tables may exist in a logical or physical data model but they are just
shown as a relationship with no cardinality under the conceptual data model.
NOTE: Conceptual ERD supports the use of generalization in modeling the ‘a kind of’ relationship
Logical ERD is a detailed version of a Conceptual ERD. A logical ER model is developed to enrich a
conceptual model by defining explicitly the columns in each entity and introducing operational and
transactional entities. Although a logical data model is still independent of the actual database
system in which the database will be created, you can still consider that if it affects the design.
Normalization is the process of minimizing redundancy from a relation or set of relations. Redundancy in
relation may cause insertion, deletion, and update anomalies. So, it helps to minimize the redundancy in
relations. Normal forms are used to eliminate or reduce redundancy in database tables.
Normalization of DBMS
In database management systems (DBMS), normal forms are a series of guidelines that help to ensure that
the design of a database is efficient, organized, and free from data anomalies. There are several levels of
normalization, each with its own set of guidelines, known as normal forms.
• Second Normal Form (2NF): 2NF eliminates redundant data by requiring that each non-key
attribute be dependent on the primary key. This means that each column should be directly related to
the primary key, and not to other columns.
• Third Normal Form (3NF): 3NF builds on 2NF by requiring that all non-key attributes are
independent of each other. This means that each column should be directly related to the primary
key, and not to any other columns in the same table.
• Boyce-Codd Normal Form (BCNF): BCNF is a stricter form of 3NF that ensures that each
determinant in a table is a candidate key. In other words, BCNF ensures that each non-key attribute is
dependent only on the candidate key.
Normal forms help to reduce data redundancy, increase data consistency, and improve database
performance. However, higher levels of normalization can lead to more complex database designs and
queries. It is important to strike a balance between normalization and practicality when designing a
database.
• Improved data consistency: Normalization ensures that data is stored in a consistent and
organized manner, reducing the risk of data inconsistencies and errors.
• Simplified database design: Normalization provides guidelines for organizing tables and data
relationships, making it easier to design and maintain a database.
• Improved query performance: Normalized tables are typically easier to search and retrieve data
from, resulting in faster query performance.
Overall, using normal forms in DBMS helps to improve data quality, increase database efficiency, and
simplify database design and maintenance.
Example 1 – Relation STUDENT in table 1 is not in 1NF because of multi-valued attribute STUD_PHONE. Its
decomposition into 1NF has been shown in table 2.
Example
Example
Example 2 –
ID Name Courses
------------------
1 A c1, c2
2 E c3
By: Mr. Emmanuel Koroma
3 M C2, c3
In the above table Course is a multi-valued attribute so it is not in 1NF. Below Table is in 1NF as there is no
multi-valued attribute
ID Name Course
------------------
1 A c1
1 A c2
2 E c3
3 M c2
3 M c3
NOTE: 2NF tries to reduce the redundant data getting stored in memory. For instance, if there are 100
students taking C1 course, we don’t need to store its Fee as 1000 for all the 100 records, instead, once we
can store it in the second table as the course fee for C1 is 1000.
In the above relation, AB is the only candidate key and there is no partial dependency, i.e., any proper
subset of AB doesn’t determine any non-prime attribute.
For this relation in table 4, STUD_NO -> STUD_STATE and STUD_STATE -> STUD_COUNTRY are true.
To convert it in third normal form, we will decompose the relation STUDENT (STUD_NO, STUD_NAME,
STUD_PHONE, STUD_STATE, STUD_COUNTRY_STUD_AGE) as: STUDENT (STUD_NO, STUD_NAME,
STUD_PHONE, STUD_STATE, STUD_AGE) STATE_COUNTRY (STATE, COUNTRY)
Consider relation R(A, B, C, D, E) A -> BC, CD -> E, B -> D, E -> A All possible candidate keys in above
relation are {A, E, CD, BC} All attributes are on right sides of all functional dependencies are prime.
Example 2: Find the highest normal form of a relation R(A,B,C,D,E) with FD set as {BC->D, AC->BE, B->E}
Step 1: As we can see, (AC)+ ={A,C,B,E,D} but none of its subset can determine all attribute of relation, So
AC will be candidate key. A or C can’t be derived from any other attribute of the relation, so there will be
only 1 candidate key {AC}.
Step 2: Prime attributes are those attributes that are part of candidate key {A, C} in this example and
others will be non-prime {B, D, E} in this example.
Step 3: The relation R is in 1st normal form as a relational DBMS does not allow multi-valued or composite
attribute. The relation is in 2nd normal form because BC->D is in 2nd normal form (BC is not a proper
subset of candidate key AC) and AC->BE is in 2nd normal form (AC is candidate key) and B->E is in 2nd
BCNF
BCNF (Boyce-Codd Normal Form) is just a advanced version of Third Normal Form. Here we have some
additional rules than Third Normal Form. The basic condition for any relation to be in BCNF is that it must be
in Third Normal Form.
We have to focus on some basic rules that are for BCNF:
1. Table must be in Third Normal Form.
2. In relation X->Y, X must be a superkey in a relation.
• Data redundancy: Normal forms minimize data redundancy by organizing data into tables that
contain only unique data. This reduces the amount of storage space required for the database and
makes it easier to manage.
• Response time: Normal forms can improve query performance by reducing the number of joins
required to retrieve data. This helps to speed up query processing and improve overall system
performance.
• Database maintenance: Normal forms make it easier to maintain the database by reducing the
amount of redundant data that needs to be updated, deleted, or modified. This helps to improve
database management and reduce the risk of errors or inconsistencies.
• Database design: Normal forms provide guidelines for designing databases that are efficient,
flexible, and scalable. This helps to ensure that the database can be easily modified, updated, or
expanded as needed.