0% found this document useful (0 votes)
18 views

Database Notes

This document defines key concepts related to databases including: 1) A database is a collection of related data arranged logically and structured in tables. A DBMS allows creation and manipulation of databases. 2) Database schemas define the structure and logical view of the database at the external, conceptual, and physical levels. 3) Data definition and manipulation languages are used to define and maintain the database structure and data.

Uploaded by

Muhammad Wasif
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Database Notes

This document defines key concepts related to databases including: 1) A database is a collection of related data arranged logically and structured in tables. A DBMS allows creation and manipulation of databases. 2) Database schemas define the structure and logical view of the database at the external, conceptual, and physical levels. 3) Data definition and manipulation languages are used to define and maintain the database structure and data.

Uploaded by

Muhammad Wasif
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Database is a collection of related data arranged in a logical and

structured manner.
Data redundancy means data is repeated.
Database Management Systems (DBMS) software packages that
allow the creation and manipulation of databases.
DBMS features for developers:
1) Query Processor – executes insert, update, delete and retrieves
requests / queries to efficiently.
2) Developer Interface - Enables programmers to create user friendly
interface for data manipulation.
Relational database stores data in tables.
Advantages of Databases:
1) Reduced data redundancy,
2) Improves data consistency and data integrity,
3) Complex queries easily written,
4) Fields can easily added or removed,
5) Program-data dependence is overcome,
6) Security is improved,
7) Multiple views for users.
Database schema: structure that represents the logical view of the
entire database. Levels of schema are:
1) External - content of the database for some user.
2) Conceptual / Logical - seen by the applications and controlled
by DBA.
3) Physical / Internal - storage of the data on the disk.
Data Dictionary: Stores all the information (detail of the database
design) about the database (not contents or data) e.g. Fields, data
types, validation checks, keys, queries.
Entity(Table) : is a person, place, thing or concept about which
data can be collected and stored in database e.g. student,
employee, sales etc.
Field (Attribute): properties / characteristics of entity. Column in table.
Record(Tuple) – Information of one person or things. A row in table.
Primary key: is a field in a table that contains unique data. Candidate
key: is another key in a table which is unique.
Composite key: Collections of attributes/fields uniquely identify a tuple
rather than just one.
Foreign Key: Primary key of another table and is used to link tables
together to create relationship.
Referential Integrity: Every foreign key value has a matching value in
the corresponding primary key.
Data consistency: data is correct in relation to other data.
Entity Relationship Diagram: entities and the relationships are
shown in a diagram.
Cardinalities of relationships: number of tuples/rows in a relation.
Types: One-to-one, One-to- many, Many-to-many.
Normalization: technique that is used for designing relational
database tables to ensure that only related data are stored in a
table.
1NF: Atomics value (data cannot be broken further). No repeating
columns, unique row (PK)
2NF: Non-key attributes must be fully depending on every part of
the primary key (No partial dependencies).
3NF: No non-key attributes should depend on another non-key
attribute (No transitive dependencies)
Data Definition Language (DDL): creation of database, table
design, creating of relationships and carry and any changes to table
design.
Examples: CREATE DATABASE Employees;
CREATE TABLE EMPLOYEE_DATA
(
EmployeeID VarChar (7), NOT NULL
FirstName VarChar(),
LastName VarChar(),
DateOfBirth Date,
Gender VarChar (6),
DepartmentNumber VarChar (2),
PRIMARY KEY (EmployeeID)
);
ALTER TABLE: used to make changes in table Add a field (origin) to
table:
ALTER TABLE item ADD Origin varchar(15);
Delete field (Quantity) from table:
ALTER TABLE item DROP Quantity;
Add primary key to table
ALTER TABLE item ADD PRIMARY KEY (ID);
Data Manipulation Language (DML):
Used creation of queries and basic maintenance of the data e.g. add,
delete and amend records.
Add value / record in a table
INSERT INTO Band_Booking (BandName, BookingID)
VALUES (‘ComputerKidz’, 2546);
Change value of field of table:
UPDATE Cars SET Colour = ′Red′ WHERE RegNo = ′MH09RCM′;
Delete a record from table
DELETE FROM Cars WHERE RegNo = ′MH09RCM′
Query using SELECT (one table):
SELECT CustomerID, SoftwareID, LicenceType, Cost, ExpiryDate
FROM LICENCE
WHERE ExpiryDate <= '31/12/2019'
GROUP BY CustomerID
ORDER BY Cost;
Query using SELECT (Two tables):
SELECT FirstName, LastName
FROM EMPLOYEE_DATA, DEPARTMENT
WHERE DepartmentName = "Finance" AND Gender = "Female" AND
DEPARTMENT.DepartmentNumber =
EMPLOYEE_DATA.DepartmentNumber;

You might also like