Академический Документы
Профессиональный Документы
Культура Документы
SQL
(MISB4304)
ﻟﻐﺔ ﺑﻴﺌﺔ ﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎت
By
Dr. Romani Farid Ibrahim
2010
Course Overview
Textbook Basic Concepts
Elmasri, R., Navathe, S., "Fundamentals of
Database Systems", 5th edition, Addison Wesley, Review
2007.
1
Basic Definitions
Database: Is a collection of logically related data.
Data: Known facts that can be recorded and have an implicit meaning. (ex.
Telephone index)
Database Management System (DBMS): A software system that enables users to
define, create and maintain the database and which provides controlled access
to the database
Example of a simple
database
Student
Name Student_number class Major
Smith 17 1 CS
Brown 8 2 CS
2
Example of a simplified database catalog
3
Typical DBMS Component Modules
Schema Diagram:
An illustrative display of database schema.
Schema Construct:
A component of the schema or an object within the schema,
e.g., STUDENT, COURSE.
8
4
Example of a Database Schema
Valid State:
A state that satisfies the structure and constraints of the
database.
5
Example of a database state
Student
Name Student_number class Major
Smith 17 1 CS
Brown 8 2 CS
11
6
Real
World
facts about the world in a database more facts some more rather long facts about the world in the databse
facts about the world in a database more facts some more rather long facts about the world in the databse
facts about the world in a database more facts some more rather long facts about the world in the databse
facts about the world in a database more facts some more rather long facts about the world in the databse
facts about the world in a database more facts some more rather long facts about the world in the databse
facts about the world in a database more facts some more rather long facts about the world in the databse
Database
facts about the world in a database more facts
facts about the world in a database
facts about the world in a database
facts about the world in a database
more facts
more facts
more facts
facts about the world in a database
facts about the world in a database
Users
facts about the world in a database facts about the world in a database
facts about the world in a database facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
facts about the world in a database
Three-Schema Architecture
7
The three-schema architecture
15
Database Design
8
Database Design
Customer(CustomerID, Name, Address, …)
SalesPerson(EmployeeID, Name, Commission, … )
Order(OrderID, OrderDate, CustomerID, EmployeeID, … )
OrderItem(OrderID, ItemID, Quantity, Price, … )
Item(ItemID, Description, ListPrice, …)
17
9
Entities types
Strong entity: can exist independently (or can uniquely identify
itself).
20
10
Entity Types and Key Attributes
Key attribute is an attribute whose values are distinct for a given
entity type.
Every (regular) entity type has at least one key
Keys may be
Simple: one attribute (Stid), or
Composite: a set of attributes whose values together
uniquely identify an entity type
Name(first name, father name, grandfather name, family
name)
Each key is underlined
Person(SSN, Name, Address, Job-description, Salary). 21
Types of Keys
STUDENT(ST-NO, SSN, Name, Age, Address, GPA, Phone-no … )
Primary Key: a set of one or more attributes that uniquely
identifies entity and it has the following properties:
Uniqueness
Not Null
Minimal
Primary Key: ST-NO
Candidate key: a subset of attributes which can be used as a
primary key, but it is not chosen.
Candidate keys: SSN, ST-NO, Phone-no
11