1st Semester
1st Semester
1st Semester
DATABASE
- database is a structured collection of data that is stored and managed
electronically. The purpose of a database is to st ore, ret rieve, and manage
dat a efficiently. Databases are used in various applications, from simple
storage of records to complex data processing systems.
Example:
FILE SYSTEM
A file system manages how data is stored and retrieved in files on a storage
medium (e.g., hard drives, SSDs). Data is typically st ored in plain t ext or binary
files.
Limitations of File System:
○ Data Redundancy: Duplication of data across multiple files.
○ Data Inconsistency: Updates to data might not be reflected across all files.
○ Lack of Flexibility: Difficult to query and manage large volumes of data.
○ Poor Data Integrity: Lack of constraints and controls to ensure data
accuracy.
1. Data Redundancy
Explanation:
Data redundancy occurs when the same piece of data is stored in multiple places
within a system. This often happens in file systems where the same data is stored in
different files or locations. Redundancy can lead to several issues, such as increased
st orage cost s, more complex dat a management , and difficult ies in maint aining
dat a consist ency.
Example:
Consider a company that stores employee information in multiple files:
2. Data Inconsistency
Explanation:
Data inconsistency arises when data redundancy leads to discrepancies in the
data. If redundant dat a is not updat ed consist ently across all locat ions, different files
3. Lack of Flexibility
Explanation:
In a file-based system, data is often stored in a specific format, making it difficult to
query or retrieve data in different ways. This lack of flexibility means that complex
queries or report s are hard t o generat e, as t he dat a might not be organized in a
way t hat easily support s t hem.
Example:
Suppose a company uses plain text files to store all its sales transactions:
○ File 1: Sales_January.txt
○ File 2: Sales_February.txt
If the company wants to generate a report showing total sales for the first
quarter, it would have t o manually combine dat a from mult iple files.
Performing such tasks is cumbersome and prone to errors, reflecting the
lack of flexibility in querying and managing data.
Database Application
1. Hierarchical Database
Explanation:
A hierarchical database organizes data in a tree-like structure, where each record
has a single parent and possibly many children. This parent -child relat ionship forms a
hierarchy, similar to a family tree. The hierarchical model is particularly useful for
applications with a clear, hierarchical relat ionship among dat a it ems.
Example:
• Structure:
In this example, the company is at the top of the hierarchy, departments are
under the company, and employees are under their respective departments.
2. Network Database
Explanation:
A network database allows more complex relationships between entities compared
to the hierarchical model. Instead of a single parent, a record can have multiple
parent and child records. This is represented using a graph st ruct ure, where records
are nodes and relat ionships are edges. The network model is suitable for
applications withint num3 = (num2++)+num1;Example:
• Structure:
• Nodes: Students, Courses, Instructors.
• Edges: A student can enroll in multiple courses, and a course can have multiple
students. Similarly, an instructor can teach multiple courses, and a course can
be taught by multiple instructors.
In this example, the network structure allows for complex relationships where entities
like students, courses, and instructors are interconnected.
• Real-World Example: Integrated Data Store (IDS) is one of the earliest network
databases.
• Structure:
○ Nodes: Students, Courses, Instructors.
○ Edges: A student can enroll in multiple courses, and a course can have
multiple students. Similarly, an instructor can teach multiple courses, and a
course can be taught by multiple instructors.
In this example, the network structure allows for complex relationships where entities
like students, courses, and instructors are interconnected.
• Real-World Example: Integrated Data Store (IDS) is one of the earliest network
databases.
3. Relational Database
Explanation:
A relational database stores data in tables, where each table is composed of rows
and columns. Each row (record) represents an entity, and each column (field)
represents an attribute of that entity. Tables can be related to each other through
foreign keys, which establish relationships between different entities. Relational
databases are highly flexible and support complex queries using Structured Query
Language (SQL).
Example:
○ Application: An online retail system.
• Tables:
○ Customers: Stores customer information (e.g., customer ID, name, email).
○ Orders: Stores order information (e.g., order ID, customer ID, order date).
○ Products: Stores product information (e.g., product ID, name, price).
In this example, the Orders table can be related to both the Customers and
Products tables using foreign keys, enabling queries that retrieve customer orders,
order details, etc.
• Real-World Example: MySQL, PostgreSQL, and Microsoft SQL Server are popular
relational database management systems (RDBMS).
4. Object-Oriented Database
Explanation:
An object-oriented database (OODB) stores data as objects, similar to objects used
in object-oriented programming (OOP) languages like Java or C++. Objects contain
both data (attributes) and methods (functions). This model is particularly useful for
applications that require complex data representations, such as multimedia, CAD,
and AI systems.
Example:
○ Application: A video game management system.
• Objects:
The database environment includes the hardware, software, data, procedures, and
users associated with a database.
Components:
1. INTERNAL
3. EXTERNAL
- Userview level,
- Highest level closest to the user
- How users view the data
- User specific view or access rigght
DATA INDEPENDENCY
- refers to the capacity to change the schema at one level of the database system
without altering the schema.
TWO TYPES:
a. Physical Data Independence
- allows changes to the internal level (physical storage) without affecting the
conceptual level
Ex: lipat file sa ibang laptop, mababago lang is locations pero ung content,
database same lang, from one storage to another
- nag-iba lang storage pero di naaapektuhan iba
Example: if new fields are added to table, the view that don’t use those fields
remain.
Database management system uses computer to store, analyze, and retrieve data.
A computer cannot process dat a unless it is organized in special ways; into
characters, fields, records, files and databases.
Character
A character is the most basic element of data that can be observed and
manipulated. Behind it are t he invisible dat a element s we call bit s and byt es,
referring to physical storage elements used by the computer hardware. A character
is a single symbol such as a digit, letter, or other special character (e.g., $, #, and ?).
Bits and Bytes are the data accepted, stored, interpreted, processed and retrieved
by computer.
Field
A field contains an item of data; that is, a character, or group of characters that
are related. For instance, a grouping of related text characters such as "John Smith"
makes up a name in the field Full_Name.
A field would be established for each type of information on each column in a table.
Record
A record is composed of a group of related fields. As another way of saying it, a
record cont ains a collect ion of at t ribut es relat ed t o an ent ity such as a person or
product . Looking at the list of potential customers - the name, address, zip code and
telephone number of a single individual would constitute a record. A payroll record
would contain the name, address, social security number, and title of each
employee.
Data
Data may be defined as a known fact that can be recorded and that have
implicit meaning. For example, names, telephone numbers and addresses of the
people.
For DBMS Software, each record requires a unique identifier known as key in order to
track and analyze data effectively. The key must be completely unique to a
particular record just as each individual has a unique social security number
assigned to them.
You might think that the name field would be a good choice for a key in a
list. However, this would not be a good choice because some people might
have the same name. A key must be identified or assigned to each record for
computerized information processing to function correctly.
1. Should be able to store all kinds of data that exists in this real world. Since we need to work with all kinds of data and requirements, database
should be strong enough to store all kinds of data that is present around us.
2. Should be able to relate the entities / tables in the database by means of a relation. i.e.; any two tables should be related. Let us say, an employee
works for a department. This implies that Employee is related to a particular department. We should be able to define such a relationship between
any two entities in the database. There should not be any table lying without any mapping.
3. Data and application should be isolated. Because database is a system which gives the platform to store the data, and the data is the one which
allows the database to work. Hence there should be clear differentiation between them.
4. There should not be any duplication (redundancy) of data in the database. Data should be stored in such a way that it should not be repeated in
multiple tables. If repeated, it would be unnecessary waste of DB space and maintaining such data becomes chaos.
5. DBMS has a strong query language. Once the database is designed, this helps the user to retrieve and manipulate the data. If a particular user
wants to see any specific data, he can apply as many filtering conditions that he wants and pull the data that he needs
6. Multiple users should be able to access the same database, without affecting the other user. i.e.; if teachers want to update a student’s marks in
Results table at the same time, then they should be allowed to update the marks for their subjects, without modifying other subject marks. A good
database should support this feature.
7. It supports multiple views to the user, depending on his role. In a school database, Students will able to see only their reports and their access
would be read only. At the same time teachers will have access to all the students with the modification rights. But the database is the same.
Hence a single database provides different views to different users.
8. Database should also provide security, i.e.; when there are multiple users are accessing the database, each user will have their own levels of right s
t o see t he dat abase. Some of them will be allowed to see whole database, and some will have only partial rights. For example, instructor who is
teaching Physics will have access to see and update marks of his subject. He will not have access for other subjects. But the HOD will have full
access on all the subjects.
9. Database should also support ACID property. i.e.; while performing any transactions like insert, update and delete, database makes sure that the
real purpose of the data is not lost. For example, if a student’s address is updated, then it should make sure that there is no duplicate data is
created nor there is any data mismatch for that student.
Types of Databases
A DBMS can support many different types of databases. There exist different database types according to the number of users, the database
location(s), and the expected type and extent of use.
• A single-user database supports only one user at a time. In other words, if user A is using t he dat abase, users B and C must wait unt il user A is done.
A single-user database that runs on a personal computer is called a desktop.
• A multiuser database supports multiple users at the same time. When the mult iuser dat abase support s a relat ively small number of users (usually
fewer than 50) or a specific department wit hin an organizat ion, it is called a workgroup database. When the database is used by the entire
organization and supports many users (more than 50, usually hundreds) across many departments, the database is known as an enterprise
database.
In contrast, a data warehouse focuses primarily on storing data used to generate information required to make tactical or strategic decisions.
Such decisions typically require extensive “data massaging” (data manipulation) to extract information to formulate pricing decisions, sales
forecasts, market positioning, and so on.
Unstructured data are data that exist in their original (raw) state, that is, in the format in which they were collected. Therefore, unstructured data
exist in a format that does not lend itself to the processing that yields information.
Structured data are the result of taking unstructured data and formatting (structuring) such data to facilitate storage, use, and the generation of
information. You apply structure (format) based on the type of processing that you intend to perform on the data.
Some databases are small enough to be created and contained on your desktop computer while others are so large that they are stored on
network servers or powerful mainframe computers.
Some databases are so large that that they must be stored on a server or mainframe computer and accessed by going online. Some large,
public databases can be accessed online for a free. These are referred to as information utilities or online services. You may have heard of or
used some of the more popular online services including:
America Online - AOL Inc. is an American multinational mass media corporation based in New York, a subsidiary of V erizon Communications.
CompuServe - was the first major commercial online service provider in the United States. It dominated the field during the 1980s and remained a
major influence through the mid-1990s. (Parent organization: AOL
Microsoft Network - is a web portal and related collection of Internet services and apps for Windows and mobile devices, provided by Microsoft
and launched on August 24, 1995, the same release date as Windows 95
These online services provide access to a numerous of informat ion sources concerning weat her, news, t ravel, shopping, and a great deal more.
Even specialized public databases can be accessed online like Lexis Library, which provides access to UK legislation and law reports, legal journals
and commentary sources.
There are many other types of large databases. Many museums have put artwork online, creating virtual art museums. Most unive rsity libraries
have created electronic databases to compliment or substitute for their card catalogues.
1. It is generally more efficient and effective to search for and extract information from smaller sets of data. In other words, users can access data
more rapidly by using smaller files than by trying to access the same data in a large composite file containing vast amounts and types of data.
2. Different types of data should be accessible to different groups of people. For example, all employees may be given access to employee
information such as work location, job title, and home telephone number. Tax deduction and salary information might only be made available to
human resource personnel and the accounting department in an organization. Different functional groups in an organization require access to
different types of data. This makes sense when you consider the need to maintain some degree of security and personal privacy .
File based systems were an early attempt to computerize the manual system. It is also called a traditional
based approach in which a decent ralized approach was t aken where each depart ment st ored and
cont rolled it s own dat a wit h t he help of a dat a processing specialist . The main role of a data processing
specialist was to create the necessary computer file structures, and also manage the data within structures
and design some application programs that create reports based on file data.
DBMS:
A database approach is a well-organized collection of data that are related in a meaningful way which can
be accessed by different users but stored only once in a system. The various operations performed by the
DBMS system are: Insertion, deletion, selection, sorting etc.
• The three schema architecture is also called ANSI/SPARC architecture or three-level architecture.
• This framework is used to describe t he st ruct ure of a specific dat abase syst em.
• The three schema architecture is also used t o separat e t he user applicat ions and physical dat abase.
• The three schema architecture contains t hree-levels. It breaks t he dat abase down int o t hree different
cat egories.
In the diagram:
• Mapping is used to transform the request and response between various database levels of architecture.
• Mapping is not good for small DBMS because it t akes more t ime.
• In External / Conceptual mapping, it is necessary to transform the request from external level to
conceptual schema.
• In Conceptual / Internal mapping, DBMS transform the request from the conceptual to internal level.
○ The approach in which a particular user needs to see the data may change over time.
○ The users of the database should not worry about the physical implementation and internal workings
of the database such as data compression and encryption techniques, hashing, optimization of the
internal structures etc.
○ All users should be able to access the same data according to their requirements.
○ DBA should be able to change the conceptual structure of the database without affecting the
user’s
○ Internal structure of the database should be unaffected by changes to physical aspects of the
storage.
• Access paths.
• For Example: Specification of primary and secondary keys, indexes, pointers and sequencing.
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
relat ions. 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.
4.) Semistructured Data Model: This type of data model is different from the other three data models
• The data which is stored in the database at a particular moment of time is called an instance of the
database.
• A database schema is the skeleton structure of the database. It represents the logical view of t he ent ire
dat abase.
• A schema contains schema objects like t able, foreign key, primary key, views, columns, dat a t ypes,
st ored procedure, et c.
• A database schema can be represented by using the visual diagram. That diagram shows t he dat abase
object s and relat ionship wit h each ot her.
• A database schema is designed by the database designers to help programmers whose software will
interact with the database. The process of dat abase creat ion is called data modeling.
• A schema diagram can display only some aspect s of a schema like t he name of record t ype, dat a t ype,
and const raints. 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.
• 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.