Fundamentals Additional Midterm
Fundamentals Additional Midterm
Fundamentals Additional Midterm
Lecture Objectives:
1. Conceptual Design
2. Logical Design
3. Physical Design
Conceptual Design
This phase involves creating a high-level representation of the database that outlines
the entities, their attributes, and the relationships between entities. The Entity-
Relationship Diagram (ERD) is the primary tool used in this phase.
Example ERD
For an Online Store, the ERD would have entities such as:
Primary Key: A unique identifier for each record in a table (e.g., Customer ID,
Order ID).
Foreign Key: A field in one table that references the primary key in another
table, used to establish a relationship between tables (e.g., Order table has a
Customer ID that references Customer table).
Logical Design
After the conceptual design, the ERD is transformed into a relational schema that can
be implemented in a database. In this phase, tables are defined, and relationships
between tables are formalized.
Relational Schema
Tables: Represent entities from the ERD.
Columns: Represent attributes, and each row represents a record.
Relationships: Defined by primary and foreign keys.
Data Types: Each attribute in a table must be assigned a data type (e.g.,
VARCHAR for text, INT for integers, DATE for dates).
Constraints: Ensure data integrity, such as NOT NULL (a field must always
have a value), UNIQUE (no duplicate values), and FOREIGN KEY constraints for
relationships.
Physical Design
The Physical Design phase involves mapping the logical schema to the physical
storage in the chosen Database Management System (DBMS). This phase focuses on
optimizing the design for performance and storage efficiency.
Storage Considerations
Choosing appropriate data types based on the expected data size and
frequency of updates.
Implementing indexes to speed up query performance.
o Example: Indexing a frequently searched field like Customer ID to make
retrieval faster.
Optimization Techniques
1. Data Consistency: Ensures that data remains accurate and consistent across
the database.
o For example, in a customer order system, if a customer’s details are
updated in one place, all references to that customer should reflect those
changes.
2. Data Redundancy Minimization: Redundancy occurs when the same data is
stored in multiple places, leading to wasted space and potential inconsistencies.
A well-designed database minimizes redundancy by normalizing the data.
3. Data Integrity: Enforcing constraints (e.g., primary key, foreign key) ensures
the accuracy and consistency of the data.
o Referential Integrity: Ensures that foreign keys accurately reference
primary keys in related tables.
o Example: If a customer is deleted, all orders associated with that
customer must also be handled accordingly (cascade delete or restrict
delete).
4. Flexibility: A flexible database design allows for easy updates and
modifications as business needs evolve.
o Example: If new products are introduced or new customer data needs to
be captured, the design should allow such changes without extensive
restructuring.
RDBMS: Systems that manage data using a structured format of tables (or
relations) with predefined relationships between them. They are the foundation
for most modern database applications.
Data Storage: In Relational Database Management System (RDBMS) data is
stored in tables (relations) and relationships between data are defined using
keys.
Data Organization: In an RDBMS, data is organized in rows and columns, with
each table containing records (rows) and attributes (columns). The system
supports querying, updating, and managing data through a structured query
language (SQL).
Example: An employee database where each employee's details are stored in a
table, with relationships to other tables (e.g., departments, roles).
RDBMS
o Oracle
o Microsoft SQL Server
Components of RDBMS
o Customer Table:
Indexes are created to speed up data retrieval operations in a table. They allow
the RDBMS to find data quickly without scanning the entire table.
Example:
o An index on the Customer ID in the Order Table allows faster searching
when retrieving all orders made by a specific customer.
SQL (Structured Query Language) - is the standard language used to interact with
RDBMS. It allows users to perform various operations such as creating tables,
inserting data, updating records, and retrieving data.
CREATE: The CREATE statement is used to create a new database object, such
as a table, index, view, or database. It defines the structure of the object and
specifies the data types for each column.
o Syntax use in creating database:
INSERT: The INSERT statement is used to insert new rows of data into a table.
It can insert data into all columns or only specific columns.
o Insert a Single Row:
o INSERT INTO Students (StudentID, FirstName, LastName, BirthDate,
Gender, EnrollmentDate)
VALUES (101, 'John', 'Doe', '2001-05-15', 'M', '2024-08-01’);
o Insert a Row without Specifying All Columns:
o INSERT INTO Students (FirstName, LastName, Gender)
VALUES ('Jane', 'Smith', 'F’);
o Insert Multiple Rows:
o INSERT INTO Students (StudentID, FirstName, LastName, BirthDate,
Gender, EnrollmentDate)
VALUES (102, 'Alice', 'Johnson', '2000-04-10', 'F', '2024-07-15'),
(103, 'Bob', 'Williams',
'1999-11-22', 'M', '2024-07-20');
SELECT: The SELECT statement is used to query and retrieve data from a
database. It can fetch data from specific columns or all columns, and it can also
apply filters to select specific rows.
o Sample syntax for select:
o SELECT * FROM table_name;
o SELECT FirstName, LastName FROM Students;
Normalization in RDBMS
Why Normalize?
Avoids data redundancy: Ensures that each piece of data is stored only once.
Ensures data integrity: Prevents data anomalies (insertion, update, and deletion
anomalies).
Normal Forms
First Normal Form (1NF): Ensures that each table column contains atomic
(indivisible) values, and each entry in a column contains only one value.
o Example: A phone number column should not contain multiple phone
numbers separated by commas.
Second Normal Form (2NF): A table is in 2NF if it is in 1NF and all non-key
attributes are fully dependent on the primary key.
o Example: In a table where the primary key is a combination of two fields,
no other fields should depend on just one part of the key.
Third Normal Form (3NF): A table is in 3NF if it is in 2NF and all its attributes
are directly dependent only on the primary key.
o Example: A table with OrderID as the primary key should not store
customer details, as these should be kept in a separate Customer table.
Properties in RDBMS
Advantages of RDBMS
Data Integrity and Security: RDBMS ensures that data remains consistent
and secure using constraints and access control.
Flexibility in Querying: SQL allows complex queries to be written easily,
enabling data retrieval in various ways.
Reduced Redundancy: Data is stored only once, thanks to normalization,
reducing redundancy.
Concurrency Control: Multiple users can access the database simultaneously,
with the system ensuring isolation and consistency.
Disadvantages of RDBMS
Thank you!
Glenda M. Flores
Instructor