database conceptscsci253/csce2501material/dbconcepts v2.… · title: database concepts author:...
Post on 10-Aug-2020
1 Views
Preview:
TRANSCRIPT
1
DATABASE CONCEPTS
Dr. Awad Khalil Computer Science & Engineering Department
AUC
Databases are considered as major components in almost all recent computer application systems, including business, management, engineering, education, medicine, science, ... etc. Database technology has a major impact on the growing use of computer systems.
What is a Database? A database is simply a collection of related data. Data mean known facts that can be recorded and that have implicit meaning.
Database Properties
1. A database is a logically coherent collection of data with some inherent meaning. A random collection of data cannot be considered as a database.
2. A database represents aspects of a real system in real world. Examples of these real systems :
A hospital A bank A factory A company A university
3. A database is designed and implemented to afford the informational needs of a specific group of users. These informational needs are supported by a set of application systems running against the implemented database.
Example I
Consider a small personal database to maintain data concerning the names, telephone numbers, and addresses of the people you know
TELEPHONE DIRECTORY
NAME PHONE NO ADDRESS
Ahmed 2451615 Heliopolis Aly 2467295 Heliopolis
Badran 2977251 Nozah Sadek 3401312 Zamalek Salah 3409123 Dokkie
2
Example II
Consider a suppliers-and-parts database to maintain data concerning suppliers supplying parts for a certain company.
SUPPLIER
SNO Sname Status City
S1 Ahmed 20 Cairo S2 Badran 10 Cairo S3 Aly 10 Alex. S4 Saleh 30 Tanta S5 Sadek 20 Cairo
PART
PNO Pname Color Weight
P1 Nut Red 12 P2 Bolt Green 15 P3 Screw Blue 15 P4 Cam Red 17 P5 Cog Black 20 P6 Screw Black 14
SUPPLY
SNO PNO QTY
S1 P1 100 S1 P2 200 S1 P3 100 S2 P1 150 S2 P3 100 S4 P2 200 S4 P3 300 S5 P2 100
Database System Environment
In a database system environment, four main components can be recognized
1. Database.
2. Database Management System (DBMS).
3. Application programs.
4. Users.
3
Application Programs/Queries
Software to Process Queries/Programs
Software to Access Stored Data
DBMSSoftware
Users/Programmers
DATABASESYSTEM
Stored DatabaseDefinition
(Meta-Data)
StoredDatabase
(1)
The Database
Data in the database will be both integrated and shared .
Database management system (DBMS)
Database
Applicationprograms
End-users
Name Address Department ...........
STUDENT
Name Course ...........
ENROLLMENT
4
(2)
The Database Management System (DBMS)
The Database Management System (DBMS) is a general-purpose software that enables users to create and maintain a database. The DBMS facilitates the process of defining, constructing, and manipulating databases for various applications.
1. Defining: Data Definition Language (DDL).
2. Constructing.
3. Manipulating: Data Manipulation Language (DML).
DBMS Layers 1. Software to process Queries and Programs: (DML). The language SQL (Structured Query
Language) is a typical example of a database query language. 2. Software to access stored data
(3)
The Application Programs
These are the programs written to support the end users requirements. A given end user can access the database via one of the online applications, where he or she operates by choosing items from a menu or filling in items on a form. Such menu- or forms-driven interfaces tend to be easier to use for people who do not have a formal training in data processing.
CommonDatabase
PersonnelApplication
PayrollApplication
Personnelusers
Payrollusers
(4)
USERS
DatabaseDesigners
DatabaseAdnibistrators
System Analysts& ApplicationProgrammers
ProfessionalUsers
Casualend users
Parametricend users
Sophisticatedend users
End Users
Stand-aloneend users
Database
Users
5
Characteristics of the Database Approach 1. Self-describing nature of a database 2. Program-data independence and Data Abstraction 3. Support multiple views of the data
4. Sharing of data and multiuser transaction processing
Personnelfiles
Payrollfiles
PersonnelApplication
PayrollApplication
Personnelusers
Payrollusers
Traditional file processing approach
CommonDatabase
PersonnelApplication
PayrollApplication
Personnelusers
Payrollusers
The Database approach.
6
DATA STORING APPROACHES
1. The File-based Approach Each application has its own set of files.
Disadvantages:
Inflexibility: a “mass production facilty” – committed to processing particular queries.
Uncontrolled Redundancy: If these separate applications need to process the same data then must duplicate copies of the data i.e., each application has its own data files, several copies of the same data may exist in different applications. This leads to:
Wastage of valuable storage space. Need to input data to several files. Data inconsistency (one fact may have more than one value – various versions may occur).
Poor Enforcement of System Standards: Data names, formats, access restrictions, … etc. are not
standardized across an organization, may have many synonyms and homonyms. This makes modifications difficult and hinders sharing of data.
Limited Data Sharing: Each application has its own private file providing little opportunity for users
to share existing data. Additionally any new applications would not be able to use existing files leading to low productivity.
Progran – Data Dependency: Descriptions of files, records, data items are embedded within
application programs. Any modification to a data file requires that the application programs using that file must also be changed. In other words, program maintenance will be excessive.
2. The Database Approach The database approach improves upon file-based systems. A DBMS (Data Base Management System) does not fragment data into separate files but regards data as being stored in a large concptual repository termed as database. The DBMS handles the addition, storage, update, and retrieval of data. DBMSs are based on semantically rich data models, which can accurately represent real world data. DBMSs allow:
Persistence of Data Transaction Control Concurrency Control Recovery Control Querying Integrity Control Data Security Version Control Performance Tuning
Components of DBMS DBMS Engine Interface Subsystem (DDL, DML, DCL, Graphical User Interface, Forms Interface,
Natural Language Interface) Data Dictionary Subsystem Performance Management Subsystem Concurrency Control Subsystem
7
Data Integrity Management Subsystem Backup and Recovery Subsystem Application Development Subsystem Security Management Subsystem
Benefits of the Database Approach Ease of application development Minimal data redundancy Enforcement of standards Data can be shared Physical data independence Logical data independence Better modeling of real world data Uniform security and integrity controls Economy of scale
Risks of the Database Approach New specialized personnel Need for explicit backup Organizational conflict Large size Expensive High impact of failure
Database Modelling
Database Structure AA ddaattaabbaassee ssttrruuccttuurree iiss tthhee ddeessccrriippttiioonn aanndd ddeeffiinniittiioonn ooff aallll bbaassiicc ssttrruuccttuurreess ssuucchh aass ssiimmppllee
ccoonncceeppttuuaall ffiilleess,, ddaattaattyyppeess,, rreellaattiioonnsshhiippss,, aanndd ccoonnssttrraaiinnttss tthhaatt sshhoouulldd hhoolldd oonn tthhee ddaattaa..
IInn aannyy ddaattaa mmooddeell iitt iiss iimmppoorrttaanntt ttoo ddiissttiinngguuiisshh bbeettwweeeenn tthhee ddeessccrriippttiioonn ooff tthhee ddaattaabbaassee
((SScchheemmaa)) aanndd tthhee ddaattaabbaassee iittsseellff ((IInnssttaannccee))..
Database Schema: The description of a database is called the database schema (or
the meta-data).
AA ddaattaabbaassee sscchheemmaa iiss ssppeecciiffiieedd dduurriinngg ddaattaabbaassee ddeessiiggnn aanndd iiss nnoott eexxppeecctteedd ttoo cchhaannggee
ffrreeqquueennttllyy..
TThhee ffoolllloowwiinngg iiss aa ssiimmpplliiffiieedd ddaattaabbaassee sscchheemmaa ddiiaaggrraamm::
8
A Database Schema in SQL CCRREEAATTEE TTAABBLLEE EEMMPPLLOOYYEEEE
((FFNNAAMMEE VVAARRCCHHAARR((1155)) NNOOTT NNUULLLL,,
MMIINNIITT CCHHAARR,,
LLNNAAMMEE VVAARRCCHHAARR((1155)) NNOOTT NNUULLLL,,
SSSSNN SSSSNN__TTYYPPEE NNOOTT NNUULLLL,,
BBDDAATTEE DDAATTEE
AADDDDRREESSSS VVAARRCCHHAARR((3300)),,
SSEEXX CCHHAARR,,
SSAALLAARRYY DDEECCIIMMAALL((1100,,22)),,
SSUUPPEERRSSSSNN SSSSNN__TTYYPPEE,,
DDNNOO IINNTT NNOOTT NNUULLLL,,
PPRRIIMMAARRYY KKEEYY ((SSSSNN)),,
FFOORREEIIGGNN KKEEYY ((SSUUPPEERRSSSSNN)) RREEFFEERREENNCCEESS EEMMPPLLOOYYEEEE((SSSSNN)),,
FFOORREEIIGGNN KKEEYY ((DDNNOO)) RREEFFEERREENNCCEESS DDEEPPAARRTTMMEENNTT((DDNNUUMMBBEERR))));;
CCRREEAATTEE TTAABBLLEE DDEEPPAARRTTMMEENNTT
((DDNNAAMMEE VVAARRCCHHAARR((1155)) NNOOTT NNUULLLL,,
DDNNUUMMBBEERR IINNTT,, NNOOTT NNUULLLL,,
MMGGRRSSSSNN SSSSNN__TTYYPPEE NNOOTT NNUULLLL,,
MMGGRRSSTTAARRTTDDAATTEE DDAATTEE
PPRRIIMMAARRYY KKEEYY ((DDNNUUMMBBEERR)),,
UUNNIIQQUUEE ((DDNNAAMMEE))
FFOORREEIIGGNN KKEEYY ((MMGGRRSSSSNN)) RREEFFEERREENNCCEESS EEMMPPLLOOYYEEEE((SSSSNN))));;
CCRREEAATTEE TTAABBLLEE DDEEPPTT__LLOOCCAATTIIOONNSS
((DDNNUUMMBBEERR IINNTT NNOOTT NNUULLLL,,
DDLLOOCCAATTIIOONN VVAARRCCHHAARR((1155)) NNOOTT NNUULLLL,,
PPRRIIMMAARRYY KKEEYY ((DDNNUUMMBBEERR,, DDLLOOCCAATTIIOONN)),,
FFOORREEIIGGNN KKEEYY ((DDNNUUMMBBEERR)) RREEFFEERREENNCCEESS DDEEPPAARRTTMMEENNTT((DDNNUUMMBBEERR))));;
CCRREEAATTEE TTAABBLLEE PPRROOJJEECCTT
((PPNNAAMMEE VVAARRCCHHAARR((1155)) NNOOTT NNUULLLL,,
PPNNUUMMBBEERR IINNTT NNOOTT NNUULLLL,,
PPLLOOCCAATTIIOONN VVAARRCCHHAARR((1155))
DDNNUUMM IINNTT NNOOTT NNUULLLL,,
PPRRIIMMAARRYY KKEEYY ((PPNNUUMMBBEERR)),,
UUNNIIQQUUEE ((PPNNAAMMEE))
FFOORREEIIGGNN KKEEYY ((DDNNUUMM)) RREEFFEERREENNCCEESS DDEEPPAARRTTMMEENNTT((DDNNUUMMBBEERR))));;
CCRREEAATTEE TTAABBLLEE WWOORRKKSS__OONN
((EESSSSNN SSSSNN__TTYYPPEE NNOOTT NNUULLLL,,
PPNNOO IINNTT NNOOTT NNUULLLL,,
HHOOUURRSS DDEECCIIMMAALL((33,,11)) NNOOTT NNUULLLL,,
PPRRIIMMAARRYY KKEEYY ((EESSSSNN,, PPNNOO)),,
FFOORREEIIGGNN KKEEYY ((EESSSSNN)) RREEFFEERREENNCCEESS EEMMPPLLOOYYEEEE((SSSSNN)),,
FFOORREEIIGGNN KKEEYY ((PPNNOO)) RREEFFEERREENNCCEESS PPRROOJJEECCTT((PPNNUUMMBBEERR))));;
CCRREEAATTEE TTAABBLLEE DDEEPPEENNDDEENNTT
((EESSSSNN SSSSNN__TTYYPPEE NNOOTT NNUULLLL,,
DDEEPPEENNDDEENNTT__NNAAMMEE VVAARRCCHHAARR((1155)) NNOOTT NNUULLLL,,
SSEEXX CCHHAARR,,
BBDDAATTEE DDAATTEE,,
RREELLAATTIIOONNSSHHIIPP
VVAARRCCHHAARR((88))
PPRRIIMMAARRYY KKEEYY ((EESSSSNN,, DDEEPPEENNDDEENNTT__NNAAMMEE)),,
FFOORREEIIGGNN KKEEYY ((EESSSSNN)) RREEFFEERREENNCCEESS EEMMPPLLOOYYEEEE((SSSSNN))));;
9
Database State (Instance) TThhee ddaattaa iinn tthhee ddaattaabbaassee aatt aa ppaarrttiiccuullaarr mmoommeenntt ooff ttiimmee iiss ccaalllleedd tthhee ddaattaabbaassee ssttaattee ((oorr
iinnssttaannccee))..
The Three-Layer Architecture
ExternalView1
ExternalViewn
Conceptual Schema
Internal Schema
Stored Database
End Users
External Level
Conceptual Level
Internal Level
external/conceptualmapping
conceptual/internalmapping
10
Data Independence DDaattaa iinnddeeppeennddeennccee iiss tthhee ccaappaacciittyy ttoo cchhaannggee tthhee sscchheemmaa aatt oonnee lleevveell ooff aa ddaattaabbaassee
ssyysstteemm wwiitthhoouutt hhaavviinngg ttoo cchhaannggee tthhee sscchheemmaa aatt tthhee nneexxtt hhiigghheerr lleevveell.. DDeeffiinneedd aass::
LLooggiiccaall ddaattaa iinnddeeppeennddeennccee iiss tthhee ccaappaacciittyy ttoo cchhaannggee tthhee ccoonncceeppttuuaall sscchheemmaa wwiitthhoouutt
hhaavviinngg ttoo cchhaannggee eexxtteerrnnaall sscchheemmaass oorr LLooggiiccaall ddaattaa aapppplliiccaattiioonn pprrooggrraammss..
PPhhyyssiiccaall ddaattaa iinnddeeppeennddeennccee iiss tthhee ccaappaacciittyy ttoo cchhaannggee tthhee iinntteerrnnaall sscchheemmaa wwiitthhoouutt hhaavviinngg
ttoo cchhaannggee tthhee ccoonncceeppttuuaall ((oorr eexxtteerrnnaall)) sscchheemmaass..
Data Models AA ddaattaa mmooddeell iiss aa sseett ooff ccoonncceeppttss tthhaatt ccaann bbee uusseedd ttoo ddeessccrriibbee aa ddaattaabbaassee ssttrruuccttuurree..
Classification of DBMSs
CCllaassssiiffiiccaattiioonn aaccccoorrddiinngg ttoo DDaattaa MMooddeell
High-level(conceptual)Data Models
ImplementationData Models
Low-level(physical)
Data Models
Data Models
HierarchicalRelational NetworkObject-oriented
DBMSs
HierarchicalRelational NetworkObject-oriented
11
The Relational Data Model
TThhee rreellaattiioonnaall ddaattaa mmooddeell rreepprreesseennttss tthhee ddaattaabbaassee aass aa ccoolllleeccttiioonn ooff ttaabblleess,, wwhheerree eeaacchh
ttaabbllee ccaann bbee ssttoorreedd aass sseeppaarraattee ffiillee..
EExxaammpplleess ooff ccoommmmeerrcciiaall rreellaattiioonnaall DDBBMMSSss::
DDBB22 ffrroomm IIBBMM
OORRAACCLLEE ffrroomm OOrraaccllee CCoorrppoorraattiioonn
IInnffoorrmmiixx ffrroomm IInnffoorrmmiixx
SSyyBBaassee ffrroomm OOppeennSSoofftt
SSQQLL SSeerrvveerr ffrroomm MMiiccrroossoofftt
MMSS--AACCCCEESSSS ffrroomm MMiiccrroossoofftt
An Example of a Relational Database
12
The Network Data model TThhee nneettwwoorrkk ddaattaa mmooddeell rreepprreesseennttss ddaattaa aass aa rreeccoorrdd ttyyppeess.. AAnn eexxaammppllee ooff aa nneettwwoorrkk
mmooddeell iiss kknnoowwnn aass tthhee CCOODDAASSYYLL DDBBTTGG mmooddeell..
The Hierarchical Data model TThhee hhiieerraarrcchhiiccaall ddaattaa mmooddeell rreepprreesseennttss ddaattaa aass hhiieerraarrcchhiiccaall ttrreeee ssttrruuccttuurree.. EEaacchh
hhiieerraarrcchhiiccaall rreepprreesseennttss aa nnuummbbeerr ooff rreellaatteedd rreeccoorrddss..
13
The Object-Oriented Data model TThhee oobbjjeecctt--oorriieenntteedd ddaattaa mmooddeell ddeeffiinneess aa ddaattaabbaassee iinn tteerrmmss ooff oobbjjeeccttss,, tthheeiirr pprrooppeerrttiieess,,
aanndd tthheeiirr ooppeerraattiioonnss.. OObbjjeeccttss wwiitthh tthhee ssaammee ssttrruuccttuurree aanndd bbeehhaavviioorr bbeelloonngg ttoo aa ccllaassss,, aanndd
ccllaasssseess aarree oorrggaanniizzeedd iinnttoo hhiieerraarrcchhiieess oorr aa ccyycclliicc ggrraapphhss.. TThhee ooppeerraattiioonnss ooff eeaacchh ccllaassss aarree
ssppeecciiffiieedd iinn tteerrmmss ooff pprreeddeeffiinneedd pprroocceedduurreess ccaalllleedd mmeetthhooddss..
EExxppeerriimmeennttaall OOOO pprroottoottyyppeess
TThhee OORRIIOONN ssyysstteemm ddeevveellooppeedd aatt MMCCCC,,
TThhee OOppeennOOOODDBB ssyysstteemm aatt TTeexxaass IInnssttrruummeennttss,,
TThhee IIRRIISS ssyysstteemm ddeevveellooppeedd aatt HHPP llaabboorraattoorriieess,,
TThhee OODDEE ssyysstteemm aatt AATTTT BBeellll LLaabbss,, aanndd
TThhee EENNCCOORREE//OObbSSeerrvveerr pprroojjeecctt aatt BBrroowwnn UUnniivveerrssiittyy..
CCoommmmeerrcciiaallllyy aavvaaiillaabbllee OOOO ssyysstteemmss
GGEEMM--SSTTOONNEE//OOPPAALL ooff SSeerriiooLLooggiicc,,
OONNTTOOSS ooff OOnnttoollooggiicc,,
OObbjjeeccttiivviittyy ooff OObbjjeeccttiivviittyy IInncc..,,
VVeerrssaanntt ooff VVeerrssaanntt TTeecchhnnoollooggiieess,,
OObbjjeeccttSSttoorree ooff OObbjjeecctt DDeessiiggnn,, aanndd,,
OO22 ooff OO22 TTeecchhnnoollooggyy..
Classification of DBMSs (Cont’d) CCllaassssiiffiiccaattiioonn aaccccoorrddiinngg ttoo NNuummbbeerr ooff UUsseerrss
SSiinnggllee uusseerr ssyysstteemmss ssuuppppoorrtt oonnllyy oonnee uusseerr aatt aa ttiimmee aanndd aarree mmoossttllyy uusseedd wwiitthh ppeerrssoonnaall
ccoommppuutteerrss..
MMuullttiiuusseerr ssyysstteemmss,, wwhhiicchh iinncclluuddee tthhee mmaajjoorriittyy ooff DDBBMMSSss,, ssuuppppoorrtt mmaannyy uusseerrss
ccoonnccuurrrreennttllyy..
CCllaassssiiffiiccaattiioonn aaccccoorrddiinngg ttoo NNuummbbeerr ooff SSiitteess
CCeennttrraalliizzeedd DDBBMMSS wwhheerree tthhee ddaattaa iiss ssttoorreedd aatt aa ssiinnggllee ccoommppuutteerr ssiittee.. MMoosstt DDBBMMSSss
aarree cceennttrraalliizzeedd.. AA cceennttrraalliizzeedd DDBBMMSS ccaann ssuuppppoorrtt mmuullttiippllee uusseerrss,, bbuutt tthhee DDBBMMSS aanndd
tthhee ddaattaabbaassee tthheemmsseellvveess rreessiiddee ttoottaallllyy aatt aa ssiinnggllee ccoommppuutteerr ssiittee..
DDiissttrriibbuutteedd DDBBMMSS ((DDDDBBMMSS)) ccaann hhaavvee tthhee aaccttuuaall ddaattaabbaassee aanndd DDBBMMSS ssooffttwwaarree
ddiissttrriibbuutteedd oovveerr mmaannyy ssiitteess,, ccoonnnneecctteedd bbyy aa ccoommppuutteerr nneettwwoorrkk.. MMaannyy DDDDBBMMSSss uussee aa
cclliieenntt--sseerrvveerr aarrcchhiitteeccttuurree..
top related