Documente Academic
Documente Profesional
Documente Cultură
Stored DB
Stored
Definition
Database
(Metadata)
DBMS Advantages
Controlling Redundancy.
Restricting Unauthorized Access.
Sharing data.
Enforcing Integrity Constraints
Inconsistency can be avoided.
Providing Backup and Recovery.
DBMS Disadvantages
Needs expertise to use (which is expensive)
DBMS is expensive
May be incompatible with any other available DBMS
Database Users
Database Administrator (DBA)
System Analysts
Database Designer
Application programmers
End users
Database Administrator (DBA) System Analyst Database Designer Application Programmer
Allocates space for DBMS Understands Designs DB Designs User Interface for
for installation and DB User according to the end user
deployment requirements analyst
DB backup and recovery Chooses DBMS recommendations
Db performance monitoring
Security
Example of real life project
Project that is aimed at monitoring senior peoples health using smart wearable devices
DBMS Three Level Schema/ Architecture
User models
External Schema 1 External Schema 2 External Schema 3 Viewed by
end user
Different Database Views
Logical models
Conceptual Schema Accessed by DBA
Logical model of all stored data
mapping
(tables and constraints)
Physical models
Physical Schema According to the type of the DBMS used
Data structure: how files are stored on the disk
Levels of Abstraction in a DBMS
(Three Schema Architecture) Disk
High Level (Conceptual) Physical
provide concepts that are close to describes how data is stored in
the way many users perceive data, the computer and the access
entities, attributes and relationships. path needed to access and
(Ex. ERD) search for data
Mapping and Data Independence
Mapping: It is the processes of transforming requests and results
between levels.
These mappings may be time-consuming. However, a certain amount
of mapping between the conceptual and internal levels is necessary.
1. Degree of a Relationship
a. Unary/ Recursive Emp lead
Project
Relationships (cont.)
2. Cardinality Ratio (the word that is far from the table
name)
A. One to one Emp
1
manage
1
Dept
In mapping: check participation
B. One to many Emp
M 1
Dept
work
In mapping: P.K. in 1 F.K. in Many
C. Many to many
In mapping: make a new table with composite primary key
from each table in the relation M N
Emp work Proj
Relationships (cont.)
3. Participation (the word that is close to the table name)
a. Total/ Full Dependency/ Mandatory
b. Partial/ Partial Dependency/ Optional
How to Map 1-1 cardinality
1 1
Emp manage Dept Must-Must May-May May- Must
Merge tables Like P.K(may)
Partial Total Chose PK with 1-Many F.K.(must)
(May) (Must) min. storage
(Zero or more) (One or more) size
Participation Examples
- A department may hire many employees
-An Employee may have a car. ( Zero or more)
-A Car must be assigned to particular - An employee must be employed by a department
employee
(Department membership is Optional, Employee
membership is Mandatory)
RELATIONSHIP TYPE
Relationships
E1 R E2
(Verbs) TOTAL PARTICIPATION OF E2 IN R
N
E1 R E2 CARDINALITY RATIO 1:N FOR E1:E2 IN R
ATTRIBUTE
Circles represent ATTRIBUTES
(Entity Properties) KEY ATTRIBUTE
DERIVED ATTRIBUTE
ER-to-Relational Mapping
Step 1: Mapping of Regular Entity Types
Data
ALTER
Definition DROP
Language
(DDL)
TRUNCATE
(Auto commit) Cant be rolled back since changes in DB are on hard disk
CREATE Command
Syntax
CREATE TABLE table_name
(column1 DATA_TYPE [CONS_TYPE CONS_NAME],
column2 DATA_TYPE [CONS_TYPE CONS_NAME],... )
Example
CREATE TABLE Students
(ID NUMBER(15) PRIMARY KEY, First_Name CHAR(50) NOT
NULL, Last_Name CHAR(50), Address CHAR(50), City CHAR(50),
Country CHAR(25), Birth_Date DATE);
DROP Command
Syntax
DROP TABLE table_name
Example
DROP TABLE Students
ALTER Command
ALTER TABLE statement is used to update metadata (add or
drop columns) in an existing table.
Syntax
ALTER TABLE table_name ADD column_name datatype
ALTER TABLE table_name DROP column_name
ALTER Example
LastName FirstName Address
Pettersen Kari Storgt 20
Result:
LastName FirstName Address City
Pettersen Kari Storgt 20
Examples of well-know industrial-strength relational
DBMSes include
Oracle, Microsoft SQL Server, IBM DB2, Informix
Well-know PC-based (desktop) relational DBMSes include
Microsoft Access , Microsoft FoxPro, Borland dBase
Data
UPDATE
Manipulation DELETE
Language
(DML)
SELECT
Before After
store_name Sales Date store_name Sales Date
Los Angeles $1500 Jan-05-1999 San Diego $250 Jan-07-1999
Example:
TRUNCATE TABLE customer
Select Queries
Syntax
Example Output
SELECT Ename, Salary
FROM Employee Ename Salary
WHERE Salary >5000 Mai 8000
Mahmoud 10000
Other Comparison Conditions
BETWEEN AND .. (between two values
inclusive)
Update Employee
SET salary= salary+salary*0.2
Where SSN= 102672;
Solutions (Cont.)
3. If you know that the company policy is to pay an annual commission
for each employee with specific percent equals 10% of his/her annual
salary .Display each employee full name and his annual commission in
an ANNUAL COMM column (alias).
A record in a MongoDB
SQL Vs MongoDB
Activities
Make a report (2-4 pages) with suitable illustrations on one of the
following topics
Evolution of Database Environment
Data warehousing
Business Intelligence
Discuss with illustration and suitable examples the following terms
Different types of joins
Union operators
Order by Clause
Exist Clause
Subqueries
References and Useful Links
Text book
R. Elmasr and S. B. Navathe, Database Systems, Sixth Edition, Pearson, 2010.
DBMS concepts
http://www.developer.com/db/article.php/719041/The-Elements-of-a-
Database.htm
https://www.tutorialspoint.com/dbms/dbms_overview.htm
Quizzes
https://quizlet.com/103479436/technology-in-action-chapter-11-flash-cards/
SQL tutorials
https://www.w3schools.com/sql/default.asp
https://www.techonthenet.com/sql/index.php
References and Useful Links (cont.)
Platform for online database schema generation
https://dashboard.genmymodel.com/
Microsoft Access Tutorials
https://www.gcflearnfree.org/access2016/
https://msdn.microsoft.com/en-us/library/bb243835(v=office.12).aspx
https://www.tutorialspoint.com/sql_certificate/using_ddl_statements.htm
https://www.gcflearnfree.org/access2010/introduction-to-databases/1/
MySQL DB
https://dev.mysql.com/downloads/installer/
NoSQL Databases
https://www.3pillarglobal.com/insights/exploring-the-different-types-of-nosql-databases
http://nosql-database.org/
MongoDB
https://www.mongodb.com/