Beruflich Dokumente
Kultur Dokumente
John Martin
Lecturer in IT, Higher College of Technology Sultanate of Oman
E.g.
An amount of money withdrawn from an account on particular day is a data. This data is further used for preparing balance sheet, profit-l loss statement etc. when such processing is done on data, it is called as information. So information is processed form of data
Data - a collection of facts made up of text, numbers and dates: Ahmad 35000 7/18/86 Information - the meaning given to data in the way it is interpreted: Mr. Ahmad is a sales person whose annual salary is $35,000 and whose hire date is July 18, 2006.
What is a Database
Database is an organized collection of inter related information. It is a collection of persistent data that can be shared & interrelated. Persistent Data reside on stable storage such as magnetic disk and available for ever. Interrelated Data stored as separate units can be connected to provide a whole picture. It contains conventional & non-conventional information. Conventional information - facts about persons, things, events etc., Non-conventional information - photographs, fingerprints, videos etc.,
information. When we perform some operation on the data and organize in some meaningful format, it is called as database system.
The software which allows user to create (table creation) and
maintain (insert, delete, change) database is called Database Management System (DBMS).
DBMS MS-Access, ORACLE, Ingres, INFORMIX,
DATA BASE MS
3. 4.
Database Approaches
There are two approaches for storing and maintaining the data on persistent storage.
FILE-BASED SYSTEM
FILE-BASED SYSTEM
Each programmer has their own set of data without
They are independent systems (stand alone) Application programs cannot exchange information.
EXAMPLE
STUDENTS REGISTRATION STUDENTS AFFAIRS TEACHERS
Student Information
Attendance Report
Own set of data No link / sharing Works independently Changing is be done separately
Elements of a database:
Database consists of three major elements. 1. Entities 2. Relationships 3. Procedures
Procedures - An ordered set of tasks/rule for performing some action on the database.
Example : Teachers assignment, Course Scheduling, Registering students.
Entities: Students Teachers Courses Department Relationships: Course - Teacher Student Course Teacher - Department
Drop Course
Add course
Registering students
Entities: Customers Products Employees Shopping-cart Relationships: Products - Customer Customer Shopping Cart Shopping Cart - Products Stock Updating
Billing
DATABASE SYSTEM
collection of information where repeated data are removed from the system.
Shared means that individual pieces of data in a database
DATABASE SYSTEM
STUDENTS AFFAIRS
DATABASE
LECTURES
store the details of the students such as Student-Id, Studentname, Specialization, Address, School-details, Emergencycontact number.
Apart from personal information, the college is also
maintaining a separate file named student results to store the results of the results of the students which consists of Student-Id, Student-name, Specialization, Result.
A separate file named students attendance is maintained to
store the attendance details of the students which consists the student-Id, Student-name, date-of-absent and period.
Apply file-based / Database approach In a Hypermarket a file named Product-file is used to store the information about all the products like Product-number, Product-name, Unit, Price, Stock. A separate file named Employee-file is used to maintain the details of the employees, like Employee-number, Employeename, Date-of-birth, Emp-Address, Salary. Another file named Customer-file is used to store the customer details such as Customer-no, Customer-Name, Cust-Address. A file named Sales-file is used to store the sales details such as Product-no, Product-Name, Customer-no, customername, units, price, total-amount.
objective.
To design data structure which will remain robust over time.
Redundancy of data can be reduced. Inconsistency can be avoided Data sharing Security restrictions can be applied Integrity can be maintained Data independence
College-ID 1001
STUDENTS RESULT
Student-Name SALIM
Specialization IT
Address MUSANNA
College-ID 1001
Student-Name SALIM
Specialization ENG
Result PASS
STUDENTS ATTENDENCE
College-ID 1001
Student-Name SALIM
Specialization IT
Attendance % 79
3. DATA SHARING
STUDENTS AFFAIRS
LECTURES
4. SECURITY RESTRICTIONS DBA - Database Administrators, USERS Permissions to access, modify or delete data. DBA creates users and give rights (permissions) to them to access, modify or deletion of information from table. Data is more secure in database system than file based system.
5. DATA INTEGRITY
STUDENTS AFFAIRS
LECTURES
Data that we are storing in database must satisfy some condition is called data integrity.
e.g: age > 0. such conditions are easily given in database.
The user can rely on the data given by the system because of Security restrictions and elimination of Data redundancy.
6. DATA INDEPENDENCE
Data Structures (Table Design) can be changed without changing the application programs.
USERS
APPLICATION PROGRAMS
DATA
Benefits of DBMS
Sharing of data and common interface is provided by DBMS. Less redundancy. Efficient and easy data access. Data integrity is maintained. Provides security for data. Data administration is easy. Standards can be enforced. User need not require to know about location of data on the disk. Reduced application development time.
Use of expensive hardware and software i.e. it is costly. Difficult and costly to develop, because it needs trained professionals, persons. Centralized data. Complete shut down when subject to failure.
Database Applications:
Banking: all money transactions Airlines: reservations, schedules Universities: registration of students, results of students. Sales: customers information, products info., purchases info. Online retailers: order tracking, customized recommendations Manufacturing: production, inventory, orders, supply chain Human resources: employee records, salaries, tax deductions Databases touch all aspects of our lives
1.
Hierarchical Model
It is a database management system that link records together like ordered tree.
Example
A Parent
Childs
2. Network Model
Used in early days Data is shown by rectangles Relationship is shown by lines It is shown like arbitrary graph. The Relationship is a Many-To-Many Relationship is unidirectional
Example
D
A
E B F C G
Disadvantages: Slow in processing than relational model. Difficulty in getting data. Difficult programs are required to write to get data.
3. Relational Model
Collection of tables are used to show data and their
relationship.
Data is stored in 2 dimensional tables. Table is collection of rows and columns. In relational database
Example
Data and Relationship shown by two tables. Table name Column/ Attributes STUDENT
Stud_id 1 Name Ali Mohammad Course IT ENG
STUDENT-MARKS
Stud_id Marks Mobile_No
78
95746111
Row/
Tuple
2 2 67 95111111
80
95746333
INTEGRITY CONSTRAINTS
Integrity constraints are conditions that must be true for any instance of a database. A legal instance of a relation is one that satisfies all specified Integrity constraints. Integrity constraints are specified using keys.
KEYS
A set of fields is a key. Keys provide one form of integrity
Primary key:
A primary key is a field (or combination of fields, called a composite key), which uniquely identifies a row or entity.
For example consider the following student table,
Sid Name Specialization GPA
Sid and {Sid, GPA} are super keys. Chose any one as primary key, for instance Sid. The other key becomes candidate key.
Foreign Key:
a field in one relation, which refers to a field in another. Foreign
keys are used in relational schema to represent a relationship between two relations/entities. A foreign key in one relation refers to the primary key field of the related relation/entity.
an attribute/field or combination of attribute in a table whose value
Sid
111 222 111
Cid
ITSE1100 ITDB1102 ENGL1100
Grade
A B C+
Sid
111 222 333
Name
Ali Muna Huda
Login
T015 T026 T018
GPA
3.2 3.3 3.0
111
ITSE1101
B+
Sid Primary Key
following table.
Sid
111 222 333 444 Ali Huda Muna Muna
Name
Specializat ion
IT IT ENGG IT 3.2 3 3.3 3.0
GPA
For example, Sid is foreign key in Enrollment its values match with the Student tables Sid.
Enrollment Student
Sid
111 222 111 111
Cid
ITSE1100 ITDB1102 ENGL1100 ITSE1101
Grade
A B C+ B+
Sid
111 222 333
Name
Ali Muna Huda
Login
T015 T026 T018
GPA
3.2 3.3 3.0
Data Model
A data model is an overall design of a database. It shows a data and relationship between them. It is a conceptual tool to represent the database.
The design of the database is a step-by-step procedure. It can be divided into three separate stages
For small projects the above stages can be handled by one person only, whereas in big projects each stage can be handled by separate persons.
Big Projects
Small Projects
Personal information Name - Ali Al Balushi Section -1 DOB - 04-Dec-1988 Address - Muladha Hostel - Yes GPA - 2.67
Level Table
Field Name LevelCode LevelDesc DataType Number Text Field Size Format Decimal
be determined.
What element of data you will store? How large each element can be? What kind of information each element can contain? What elements may be left blank? Which elements are considered to be of a fixed range? Whether and how various tables are linked?
Attendance Table
Course Table
Conceptual Modeling
This is the first step of database design. Relevant elements are identified and analyzed. Such as
documents like daily attendance report, students grading sheet and objects like teacher, student, library.
To analyze the information, data modeling techniques are
used.
Data Modeling techniques areA) Entity Relationship Diagram. (ERD) B) Normalization. C) Functional Dependency Diagram. (FDD)
technique which shows all entities and the relationship exists between them.
Entity Relationship Diagram is a graphical representation of
a database.
Entity Relationship Diagram
CustCity
CustID
Customer
Depositor
Account
ActNo
CustName
DOB
Balance
collected. This can be person (i.e. student, teacher), place (i.e. department), things (grade) or events (attendance).
Entity set Group of similar entities.
entities.
Relationships are classified by their degree, connectivity,
of salary attribute contain all values between 1000 and 2000 (e.g. 1500, 1890, 1999, 2000)
Degree of a Relationship
The degree of relationship is the number of entity sets associated (linked) with the relationship.
relationship
Degree = 5
set associated with another entity set via a relationship set. One To One (1:1) One To Many (1:M) Many To One (M:1) Many To Many (M:M)
One-to-One (1:1)
At most one instance of entity set A there is only
one instance of entity set B. And at most one instance of entity set B there is only one instance of entity set A. A B
e.g. Car CarNumber Country - CapitalCity Department - HeadOfDepartment
One-one
One-to-Many (1:M)
For one instance of entity set A , there are zero, one
or many instances of entity set B. But for one instance of entity set B there is one instance of entity setBA. A
e.g.
only
One-to-Many
Many-to-One (M:1)
For one instance of entity set B , there are zero, one
or many instances of entity set A. But for one instance of entity set A there is one instance of entity setBB. A
e.g.
only
Many-to-One
Many-to-Many (M:M)
For one instance of entity set A , there are zero, one or
many instances of entity set B. But for one instance of entity set B there is many instances of entity set A. B A
e.g. Employee Project Suppliers Part Author - Book Many-to-Many
One-to-Many
Consider another entity set; Department and Courses. Looking at figure below we can say that ONE department can offer MANY courses.
Marketing
Business Studies
Business Ethics
E-Business
Many-to-Many
Consider another entity set Students and Courses. Looking at figure below we can say that ONE Student is registered to MANY courses and Courses has MANY Students.
Ali Marketing
Ismail
Business Ethics
Haider
E-Business
Example ER Diagram.
CUSTOMER
HAS
ACCOUNT
HANDLES
BANK
Relationships are also sometimes expressed in verbs (action words). e.g. Department Head manages Department. On the other hand Department is managed by Department Head. A Department Head can manage only ONE department and department can have only ONE head ( 1:1 relationship)
Department Head
Manages a Managed by
Department
MR X One-to-One
IT Department
E-brary Book
Title: Databases A Beginner's Guide Author: Oppel, Andy ISBM:9780071608473 Chapters: 1,7