Professional Documents
Culture Documents
CSC 111 (Introduction To Database Concepts & It Application)
CSC 111 (Introduction To Database Concepts & It Application)
COURSE OUTLINE: -
1. Introduction to Databases
3. Database Design
Denormalization
Aggregate functions
5. Database Management
1
Transaction management
6. Applications of Databases
7. Final Project
INTRODUCTION TO DATABASES
A database is a structured collection of data organized in a way that a computer program can
quickly select and retrieve desired pieces of information. Databases are designed to manage
and store large amounts of information efficiently. The primary purpose of databases is to
provide a systematic and organized approach to storing, managing, and retrieving data,
The evolution of database systems can be traced through various stages, each marked by
2
File-Based Systems: Early computer systems relied on flat file structures to store and
retrieve data. This approach had limitations in terms of data redundancy and
consistency.
introduced relationships between data entities, allowing for more complex data
structures.
Relational Databases: In the 1970s, Edgar F. Codd introduced the relational model,
tables with rows and columns, simplifying data manipulation and retrieval.
were developed to handle complex data structures and relationships more effectively.
NoSQL Databases: As the demand for handling large volumes of unstructured and
semi-structured data grew, NoSQL (Not Only SQL) databases emerged. These
databases are designed to be more flexible and scalable than traditional relational
databases.
Relational Databases:
NoSQL Databases:
3
Accommodate unstructured and diverse data types.
Object-Oriented Databases:
Graph Databases:
organization, and management. It acts as an intermediary between the database and the end-
Data Definition Language (DDL): Allows users to define the structure of the
4
RELATIONAL DATABASE CONCEPTS
A relational database is a type of database that organizes data into one or more tables, where
each table consists of rows and columns. The tables are related to each other based on
common fields, allowing for the establishment of relationships between data points. This
structure enables efficient storage, retrieval, and manipulation of data, using a standardized
query language such as SQL (Structured Query Language). Relational databases are widely
used in various applications and industries due to their flexibility, scalability, and ability to
enforce data integrity through constraints and relationships. Examples of relational database
management systems (RDBMS) include MySQL, PostgreSQL, Oracle, SQL Server, and
SQLite.
4. Primary Key: A unique identifier for each row in a table, used to enforce entity
5. Foreign Key: A field in one table that refers to the primary key in another table,
6. Index: A data structure that improves the speed of data retrieval operations on a
7. Query: A request for data retrieval or manipulation from a database, typically written
5
8. Normalization: The process of organizing the data in a database to reduce redundancy
11.View: A virtual table generated from the result of a database query, allowing users to
12.Stored Procedure: A precompiled and stored set of SQL statements that can be
applications.
15.Backup and Recovery: Processes and procedures for creating copies of database files
Tables: In a relational database, data is organized into tables. Each table represents a
specific entity or concept and consists of rows and columns. Columns are also known
as attributes, representing the characteristics of the entity, while rows contain the
6
Records: A record is a complete set of data corresponding to a single instance of an
entity. Each row in a table is a record, and it holds information about a specific
occurrence or item.
characteristics of the data stored in a table. For example, in a "Customers" table, fields
Primary Key: A primary key is a unique identifier for each record in a table. It
ensures that each row can be uniquely identified, and no two rows have the same
primary key. The primary key is crucial for data integrity and for establishing
Foreign Key: A foreign key is a field in a table that refers to the primary key in
another table. It creates a link between the two tables, establishing a relationship. This
corresponds to exactly one record in another table. This type of relationship is used
when the entities being related have a unique and singular connection.
be related to multiple records in another table, but each record in the second table can
only be related to one record in the first table. This common relationship represents
7
Many-to-Many Relationship: In a many-to-many relationship, each record in one
table can be associated with multiple records in another table, and vice versa. To
to connect the two tables. This is often seen in complex scenarios where entities can
model that illustrates the entities, attributes, and relationships between tables in a
Components of ERD:
or concept.
connected to entities.
many, or many-to-many).
DATABASE DESIGN
Database Design is the process of defining the structure that will organize and store data in a
database system. It involves making decisions on how data will be stored, accessed, and
managed within the database, with the ultimate goal of ensuring data accuracy, efficiency,
8
and security. The database design process encompasses both the logical and physical aspects
1. Entity: A distinct object, concept, or thing about which data is stored in a database.
database table.
4. Primary Key: A unique identifier for each record in a table, used to ensure data
5. Foreign Key: A field in one table that refers to the primary key in another table,
8. Index: A data structure that improves the speed of data retrieval operations on a
9
11.Cardinality: The numerical relationship between two entities in a database
relationship, indicating how many instances of one entity are associated with each
NORMALIZATION
creating tables and establishing relationships between those tables according to rules
designed both to protect the data and to make the database more flexible by eliminating
Normalization typically involves dividing large tables into smaller ones and defining
relationships between them. The objective is to isolate data so that additions, deletions, and
modifications can be made in just one table and then propagated through the rest of the
There are several normal forms, each building on the previous one, which define the levels
10
1. First Normal Form (1NF): In 1NF, each table cell should contain a single, atomic
value, and there should be no repeating groups or arrays of data. This ensures that each
column represents a single attribute, and each entry in the table is indivisible.
2. Second Normal Form (2NF): 2NF builds on 1NF by ensuring that no partial
the entire primary key. This eliminates redundancy by breaking the table into smaller,
3. Third Normal Form (3NF): 3NF extends the normalization process by removing
transitive dependencies. In a 3NF table, non-key attributes should not depend on other
non-key attributes. This further reduces redundancy and ensures data consistency.
5. Fourth Normal Form (4NF) and Fifth Normal Form (5NF), also known as "Domain-
Key Normal Form" (DK/NF), deal with certain types of multivalued dependencies and
join dependencies.
2. DENORMALIZATION:
performance is critical, and the database is read-intensive. It involves merging tables and
ADVANTAGES OF DENORMALIZATION:
11
Faster Query Performance: Redundant data can reduce the need for joins, resulting in
Simplicity: Denormalized structures can simplify complex queries, making them more
Considerations:
duplicated data.
Update Anomalies: Redundant data introduces the risk of update anomalies, where
Database Design is the process of defining the structure that will organize and store data in a
database system. It involves making decisions on how data will be stored, accessed, and
managed within the database, with the ultimate goal of ensuring data accuracy, efficiency,
and security. The database design process encompasses both the logical and physical aspects
The database design process involves several steps to create an efficient, well-structured
database that meets the requirements of the users and the organization. Here's a typical
1. Requirements Gathering: This initial phase involves understanding the needs of the
users and the organization. It includes identifying the data to be stored, the
relationships between different data elements, and the anticipated usage patterns of the
database.
12
2. Conceptual Design: In this phase, a high-level conceptual model of the database is
represent the entities, attributes, and relationships in the system, without getting into
3. Logical Design: During this stage, the conceptual model is translated into a logical
(DBMS). This includes defining tables, columns, data types, constraints, and
4. Schema Refinement: Once the logical design is in place, it may undergo refinement
5. Physical Design: In this phase, the logical model is translated into a physical database
implemented on the chosen DBMS platform. This may involve creating tables,
indexes, views, stored procedures, and other database objects according to the
ensure that it meets the functional and performance requirements specified during the
13
design phase. This may involve unit testing, integration testing, performance testing,
8. Deployment: Once testing is complete and the database is deemed ready for
migrating data from existing systems, configuring access controls, and setting up
9. Maintenance and Evolution: After deployment, the database will require ongoing
requirements over time. This may involve monitoring system performance, applying
patches and updates, and making enhancements to the database schema as needed.
developers, and stakeholders is crucial to ensure that the resulting database meets the needs
way to interact with relational database management systems (RDBMS) to create, retrieve,
update, and delete data. SQL is widely used across various industries and plays a crucial role
14
1. Basic SQL Commands (SELECT, INSERT, UPDATE, DELETE):
SELECT: The ‘SELECT’ statement is used to retrieve data from one or more tables. It
allows you to specify the columns you want to retrieve, apply conditions, and order the
results.
Example:
Example:
Example:
Example:
WHERE Clause: The ‘WHERE; clause is used to filter data based on specified
conditions.
Example:
ORDER BY Clause: The ‘ORDER BY’ clause is used to sort the result set based on one or
15
Example:
Joins: Joins are used to combine rows from two or more tables based on a related
column between them. Common types of joins include INNER JOIN, LEFT JOIN (or
LEFT OUTER JOIN), RIGHT JOIN (or RIGHT OUTER JOIN), and FULL JOIN.
Example:
table2.column;
Subqueries: A subquery is a query nested within another query. It can be used within
SELECT, FROM, WHERE, and other clauses to perform operations on the result of the
subquery.
Example:
4. Aggregate Functions:
16
Example:
1. Data Definition Language (DDL): SQL includes commands for defining and
managing the structure of the database, such as creating and altering tables, defining
column1 datatype,
column2 datatype,
...
);
and querying data within the database. This includes retrieving data using the ‘SELECT’
statement, inserting new records with ‘INSERT’, updating existing records with an
17
UPDATE table SET column1 = value1 WHERE condition;
3. Data Query Language (DQL): SQL is commonly used for querying data from one or
more tables. The ‘SELECT’ statement is a powerful tool that allows users to retrieve
specific columns, filter data based on conditions, sort results, and aggregate data.
SELECT column1, column2 FROM table WHERE condition ORDER BY column1 ASC;
Data Control Language (DCL): SQL includes commands for controlling access to data
within the database. This includes granting or revoking permissions, and ensuring data
transactions, ensuring that a series of related operations are completed successfully or rolled
COMMIT;
ROLLBACK;
18
SQL is a standardized language, and while different database management systems may have
specific variations or extensions, the core principles and syntax remain consistent. The
language's versatility makes it an essential tool for working with relational databases in
DATABASE MANAGEMENT
manipulation of data within a database system. It encompasses a set of activities, tools, and
processes aimed at ensuring data integrity, security, and accessibility. The primary goal of
database management is to provide a structured and efficient mechanism for storing and
managing data, enabling users and applications to interact with the database in a controlled
Tables define the entities, their attributes, and the relationships between them.
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT,
19
);
Modifying Structures: As the data requirements evolve, database administrators may need
to modify the database structure. This involves altering tables, adding or removing columns,
Example:
3. Transaction Management:
single unit of work. Transaction management ensures that a series of related database
the database.
Example:
BEGIN TRANSACTION;
-- SQL statements
COMMIT;
Atomicity: Transactions are treated as atomic units, ensuring that either all
20
Consistency: Transactions bring the database from one consistent state to
another.
interference.
Data Integrity: Data integrity ensures the accuracy and consistency of data within the
Constraints:
a unique identifier.
integrity.
Example:
CustomerID INT,
OrderDate DATE,
);
21
5. Indexing and Optimization:
Indexing: Indexes are structures that enhance the speed of data retrieval operations on
a database table. They work similarly to an index in a book, allowing the database
Example:
and operations. This may include proper indexing, query optimization, and database
design considerations.
Query Optimization: Analyzing and optimizing the SQL queries to improve their
security, and efficiency of data storage and retrieval. Proficient database management
practices contribute to the reliability and performance of applications and systems that rely
on data-driven operations.
APPLICATIONS OF DATABASES
Data Storage and Retrieval: Businesses and industries use databases to store and
manage vast amounts of structured and unstructured data efficiently. This includes
22
Transaction Processing: Databases facilitate real-time transaction processing,
centralize customer data, providing insights into customer behavior, preferences, and
Data Warehousing: Organizations use data warehouses to consolidate and store data
to analyze historical data trends, generate reports, and make informed strategic
Data Mining: Data mining involves extracting valuable patterns and knowledge from
with attribute data (non-spatial information) to create layered maps. Databases in GIS
23
store, manage, and analyze geographic data, facilitating applications in urban
based services, providing users with information based on their geographical location.
natural resources, such as water, forestry, and agriculture, by analyzing spatial patterns
and trends.
Big Data: Databases play a crucial role in handling and analyzing massive volumes of
data, known as Big Data. Traditional relational databases may struggle with the scale
semi-structured data and are commonly used in applications with high data volumes
Real-Time Analytics: Big Data and NoSQL databases support real-time analytics,
particularly valuable in areas like social media analysis, cybersecurity, and financial
trading.
24