Professional Documents
Culture Documents
SQL
MariaDB IBM DB2 MySQL
SERVER
• The origins of PostgreSQL date • MS Access still remains one of • A C-language library that • A general-purpose relational
back to 1986 as part of the the top 10 databases for local data implements a small, fast, self- database-as-a-service (DBaaS)
POSTGRES project at the storages. contained, high-reliability, full- based on the latest stable version
University of California at • Access is usually not used in featured, SQL database engine of Microsoft SQL Server
Berkeley and has more than 30 remote or centralized storage. It is Database Engine
years of active development on used for local small databases
the core platform. The current
version of PostgreSQL is 11.4 that
was released on 20 June 2019
PostgreSQ Microsoft
SQL Lite Azure SQL
L Access
2.1.3 DESCRIBE THE COMPONENTS OF A RELATIONAL
DATABASE STRUCTURAL TERMINOLOGY
COMPONENTS OF A RELATIONAL DATABASE
a. Relation (Table)
b. Tuple (Row of record)
c. Cardinality of a Relation (Number of rows)
d. Attribute (Column or field)
e. Degree of a relation (Number of columns)
f. Primary key (Unique identifier)
g. Domain (Pool of values of specific attributes of relation)
Relation
RELATION
• A table (TABLE)
is the same as a record, which is the fundamental data component.
• Comprised of a set of fields that are the same in every table or record,
such as the name, address and product of the customer.
Tuple
• A tuple is a row of a relation
Cardinality
• The number of tuples its contains.
• Example : If Branch relation have 5 number of tuples, the cardinality of
Branch relation is 5.
Attribute
• Named column of relation.
Degree
RELATION (TABLE)
• The degree of relation is the number of attributes it contains.
• Example : Student relation that have four attributes, so the degree is four.
Primary Key
• Is an attributes that uniquely identify each rows.
Domain
• Set of possible values for an attribute.
• Each simple attribute of entity is associated with value set (domain of
values).
• It specify the sets value that may be assigned to that attribute for each
individual entity.
• Example : Given an attribute named Gender, the domains are MALE and
FEMALE
2.1.4 IDENTIFY THE APPLICATION AREAS OF
RDBMS
Banking transactions.
Universities
2.1.5 PROPERTIES OF TABLES IN A
RELATIONAL DATABASE
Relation Name
Relation name is distinct from all other relation names in relational
schema.
Cannot have two Student relation in the database
Attribute Name
Each attribute has a distinct name
Order of attributes has no significance
Order or tuples has no significance, theoretically
Domains
PRIMARY KEY
A column or group of columns in a table which helps us to
uniquely identifies every row in that table is called a
primary key.
The same value can't appear more than once in the table.
Rules for defining Primary key:
Two rows can't have the same primary key value
It must for every row to have a primary key value.
The primary key field cannot be null.
The value in a primary key column can never be modified or updated if
any foreign key refers to that primary key.
PRIMARY KEY
CANDIDATE KEY
A super key with no repeated attribute is called candidate key.
The Primary key should be selected from the candidate keys.
Every table must have at least a single candidate key.
Properties of Candidate key:
It must contain unique values
Candidate key may have multiple attributes
Must not contain null values
It should contain minimum fields to ensure uniqueness
Uniquely identify each record in a table
CANDIDATE KEY
2.1.8 RELATION KEYS
FOREIGN KEY
A foreign key is a column which is added to create a relationship with
another table.
Foreign keys help us to maintain data integrity and also allows
navigation between two different instances of an entity.
Every relationship in the model needs to be supported by a foreign
key.
FOREIGN KEY
FOREIGN KEY
ALTERNATE KEY
All the keys which are not primary key are called an alternate key. It is a
candidate key which is currently not the primary key. However, A table may
have single or multiple choices for the primary key.
Example: In this table.
StudID, Roll No, Email are qualified to become a primary key. But since
StudID is the primary key, Roll No, Email becomes the alternative key.
COMPONENT OF RELATIONAL SCHEMA
GROUP ACTIVITY
2.1.9 EXPLAIN TWO IMPORTANT INTERGRITY
RULES
INTEGRITY
REFERENTIAL INTERGRITY
REFERENTIAL INTERGRITY
2.1.10 APPLY THE CONCEPTS OF RELATIONAL DATABASE USING
AN APPROPRIATE DESKTOP DATABASE BY CREATING TABLES
A relational database stores data in tables (relation), which are organized into
columns (attributes). Each column stores one datatype (integer, real number, string,
date etc.) and each row (tuple) represents an instance of the table.
EXPLAIN OPERATORS OF RELATIONAL
ALGEBRA
2.2.1 DESCRIBE THE RELATIONAL ALGEBRA
2.2.2 IDENTIFY THE FUNDAMENTAL OPERATORS USED TO RETRIEVE INFORMATION
FROM A RELATIONAL DATABASE2.2.3 DESCRIBE THE PURPOSE AND INPUT OF EACH
OF THE OPERATORS AND EXPRESSION
2.2.4 WRITE THE EXPRESSIONS BY USING THE OPERATORS BASED ON RELATIONAL
TABLES GIVEN
2.2.5 ILLUSTRATE THE EXPRESSION OUTPUT
2.2.6 DEFINE THE TRADITIONAL SET OF OPERATORS FOR RELATIONAL TABLES: A.
UNION B. INTERSECTION C. DIFFERENCE
2.2.7 DEFINE UNION COMPATIBILITY
2.2.8 ILLUSTRATE THE UNION, INTERSECT, AND DIFFERENCE SET OPERATORS BASED
ON TABLES GIVEN
2.2.1 DESCRIBE THE RELATIONAL
ALGEBRA
A collection of operators that
Are defined on relations
Produce relations as results
Can be combined to form complex expressions
Operators:
To retrieve information : Restrict, Project, Join, Cross
Product
Traditional set theory: Union, Intersection, Difference
RELATIONAL ALGEBRA
Symbolic notation to represent the operators:
SELECT σ (sigma)
PROJECT (pi)
PRODUCT (times)
JOIN ⋈
(bow-tie)
UNION (cup)
INTERSECTION (cap)
DIFFERENCE - (minus)
2.2.2 IDENTIFY THE FUNDAMENTAL OPERATORS USED TO
RETRIEVE INFORMATION FROM A RELATIONAL DATABASE
SELECT
The selection or operation selects rows from a table that satisfy a condition
The SELECT operation can be viewed as a horizontal filter of the relation.
R1 ⋈θ R2
1.
2.
3.
SOLUTION
1.
2.
3.
2.2.5 ILLUSTRATES THE EXPRESSION OUTPUT
EXAMPLE
Figure out which relational algebra operations were used to obtain each of the
following tables.
a. b.
SOLUTION
2.2.6 DEFINE THE TRADITIONAL SET OF OPERATORS
FOR RELATIONAL ALGEBRA TABLES
UNION
Venn Diagram
UNION
UNION EXAMPLE
INTERSECTION
Venn Diagram
INTERSECTION
INTERSECTION EXAMPLE
DIFFERENCE
The DIFFERENCE operation finds the set of tuples that exist in one relation but
do not occur in the other union compatible relation
Notation: r1 \ r2
Venn Diagram
DIFFERENCE
DIFFERENCE EXAMPLE
2.2.7 DEFINE UNION COMPATIBILITY
UNION
INTERSECT
DIFFERENCE / MINUS