Lec 09 22102023 041515pm

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 67

CSC-110

Computing FUNDAMENTALS
FUNDAMENTALS OF DATABASE
What is a database?
Databases are everywhere, but you never see them.
They are hidden behind the tools and services that you use
everyday.
Ever wondered where facebook, and twitter put their data?
It’s all stored in the database.
What is a database?
Where do google store it’s pages?
Where are the contacts in your mobile phone stored?
What is a database?
Databases do most of the work and the information systems
that we use every day.
So what is a database? Is it just a random collection of stuff
all squeezed in together.
No, databases are organized. Databases have a structure and
all the data we store in them fits into this structure.
What is a database?
What is a database?
Simple type of databases are called flat-file databases.
They store data in columns of fields and rows called records.
What is a Record?
A complete set of information.
Records are composed of fields.
What is a field?
A space allocated for a particular item or information.
A collection of fields is called a record.
Example
 Let’s think about a simple database that Ibrahim uses to store his address book.
 This address book contains names, addresses, birthdays, and telephone numbers
of his friends and family.
Example
Ibrahim has met his friend Megan, would like to add her to
his address book.
He writes down her First Name, Last Name, address, post
code, date of birth and her telephone number.
example
The details that Ibrahim writes down are stored in fields in his
address book database.
Example
The information about Megan fills a row in his database file.
Example
Each row is called a record and each of the rows holds information
about a different person in his address book.
Example
 Ibrahim can carry out operations on his stored database, he can search it to find a
particular person.
Example
Ibrahim can make the search more accurate by selecting the field he wants
. So, he can ask the database to return all the records where the first name
= to Megan.
Example
Or Ibrahim could ask the database to show everyone with a birthday in
December.
Example
Example
He can sort the database to show the records in a different order.
EXAMPLE
Fields can store different types of data.
Example
example
Representation or Implementation Data Model-

Relational Database model


Relational database model is the most common type of
database model.
Table, record, field, key, and data values are the terms
associated with a relational model. The data elements are
stored in different tables made up of rows and columns. The
data in different tables are related through the use of
common data elements.
Representation or Implementation Data Model-
Relational Database model
Table: group of records is called a Table.

For example a table for


student profile can have four
columns namely, name, age,
address, and
hobby, and have records or
rows having data of 30
students.
Representation or Implementation Data Model-
Relational Database model
Data Values Data values are the raw data represented in numeric,
character, alphanumeric, or alphabetic form. Examples of data values
are ‘Ali’, ‘26’ ‘shooting’, “Karachi” etc.
Field or Column Data values or data is stored in a database as fields.
For an item or object, a field holds the information of it. For example,
individual fields or columns are name, age, address, hobby etc. for an
object ‘student profile’.
 Record or Row A group of data for related field is called a record. For
example, for object ‘student profile’, the related fields are (name, age,
address, and hobby). The data about the student #1 (‘Ali’, 26, ‘Karachi’,
and ‘Shooting’) is one record.
Representation or Implementation Data Model-
Relational Database model
Key A key is an identifier in a table that uniquely identifies a row in
a table. The key identifier can be the value of a single column or of
multiple columns. A key is generally also referred to as the primary
key or a foreign key of the table. The primary key is a unique
identifier for the table.
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model

Note that the


CategoryID in the
Sweets Table doesn’t
contain unique values.
This special column is
used to link the Sweets
and Category Tables
together.
The CategoryID in the
Sweets Table is still a
key column but we call
this type of key a
Foreign Key.
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model-
Relational Database model
Representation or Implementation Data Model
Relational Database model
High-level or conceptual database model
The conceptual data model is a description of the data
requirements of the user.
It ensures that all the functional and data requirements of
the users are specified, conceptually.
The conceptual model is defined usin terms like (1) Entity,
(2) Attribute, and (3) Relationship.
The Entity-Relationship model (E-R model) is an example
of conceptual data model.
High-level or conceptual database model- entity
ENTITY: It is a real-world object that exists physically or
conceptually, such as person, places, things, or events
which have relevance to the database. Some specific
examples of entities that exist physically are Employee,
Student, Lecturer. Some specific examples of entities that
exist conceptually are Event, job title, etc..
High-level or conceptual database model- entity
High-level or conceptual database model-entity
High-level or conceptual database model- attribute
An attribute describes some property or characteristics of the entity.
For e.g. student name, student address, and student age are attributes
of the entity student_profile.
ENTITY
Entities
High-level or conceptual database model- attribute
High-level or conceptual database model- relationship
An association or link between two entities is represented
using a relationship.
Cardinality: The cardinality of a relationship is the number
of instances of entity B that can be associated with entity A.
The cardinality ratio of a relationship set is any one of the
four kinds—(1) One-to-One, (2) One-to-Many, (3) Many-to-
One, and (4) Many-to-Many.
High-level or conceptual database model- relationship
 In two entity sets A and B, the different cardinality ratio imply the
 following:
 One-to-One: An entity in A is associated with at most one entity in B and vice
versa.
 One-to-Many: An entity in A is associated with any number of entities in B, but
an entity in B is associated with at most one entity in A.
 Many-to-One: An entity in A is associated with at most one entity in B, but an
entity in B is associated with any number of entities in A.
 Many-to-Many: An entity in A is associated with any number of entities in B and
vice versa.
relationship
ONE-TO-ONE
PERSON
PERSON ID NAME EMAIL PASSPORT
ADDRES DETAILS
S
PASSPOR PASSPORT PERSO
1 ALI ali.we@ya T ID NUMBER N ID
hoo.com
100 WER12TYG 1
2 Anum anum12@
101
gmai.com AB56DJU7 2
3 Saad s.khan@h 102
otmail.co T2ASD455 3
m
ONE-TO-ONE
ONE-TO-MANY or many-to-one

BOOK AUTHOR

BOOK BOOK ISBN AUTHO FULL BOOK


ID TITLE R ID NAME ID
101 JOHN 1
1 LET IT ISBN30
SMITH
SNOW 2345
102 RANA 1
2 THREE ISBN56 SOHAIL
CUPS 2439 103 JOEL 2
OF MARK
TEA 104 PATRIC 2
JO
One-to-many

CUSTOMER ORDERS
CUSTOMER ID CUSTOME ORDERS CUSTOME ORDERS AMOUNT
R NAME ID R ID DATE

101 JOHN JOE 555 101 12/11/2017 RS. 5000

102 BILL 556 102 13/11/2017 RS. 2500


SPARK 557 101 14/11/2017 RS. 1500
MANY-TO-MANY

ORDERS ITEMS
ORDERS CUSTOME ORDERS AMOUNT ORDERS ID ITEMS ID
ID R ID DATE
555 201
555 101 12/11/2017 RS. 5000
555 202
556 102 13/11/2017 RS. 2500
557 101 14/11/2017 RS. 1500 556 202
556 203
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
ER Model is best used for the conceptual design of a
database.
ER Model is based on −
Entities and their attributes.
Relationships among entities.
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
High-level or conceptual database model- ENTITY
RELATIONSHIP MODEL
Representation or Implementation Data Model-
HEIRARCHICAL DATABASE MODEL
Representation or Implementation Data Model-
NETWORK DATABASE MODEL
DATABASE MANAGEMENT SYSTEM
Database management systems (DBMSs) are specially
designed software applications that interact with the user,
other applications, and the database itself to capture and
analyze data.
Well-known DBMSs include MySQL, MariaDB,
PostgreSQL, SQLite, Microsoft SQL Server, Oracle, SAP,
dBASE, FoxPro, IBM DB2, LibreOffice Base and
FileMaker Pro.
DATABASE MANAGEMENT SYSTEM
A typical DBMS has users with different rights and permissions who use it
for different purposes. Some users retrieve data and some back it up. The
users of a DBMS can be broadly categorized as follows −
DATABASE MANAGEMENT SYSTEM

 Administrators - Administrators maintain the DBMS and are responsible for


administrating the database. They are responsible to look after its usage and by whom it
should be used. They create access profiles for users and apply limitations to maintain
isolation and force security. Administrators also look after DBMS resources like
systern license, required tools, and other software and ha rdware related maintenance.
 Designers /Application Programmers— Designers are the group Of people who actually
work on the designing part of the database. They keep a close watch on what data
should be kept and in what format. They identify and design the whole set Of entities,
relations, constraints, and views.
 End Users — End users are the people who interact with the database system to get
information from the database to carry out their business responsibility. They interact
with the system through menus or forms. These users can also interact with the system
using query languages which requires some expertise for its use. End users include
people like executives, managers, clerical staff, bank teller, and so on.
example

You might also like