Post on 18-Mar-2018
Database Review
Outline
DefinitionsHistoryBasic concepts of DBMSData ModelsRelational databaseNormalization
Definitions
Database: an organized collection of dataRelational database: a database based on
the relational modelDatabase management system: a
computer program (or a suite of programs)designed to manage a database, and runoperations on the data requested bynumerous consumers
Source: www.en.wikipedia.org
History
1960's: Two main data models were developed:network model (CODASYL - COnference onDAta SYstems Languages) and hierarchical(IMS - Information Management System).
1970-72: Edgar Frank Codd proposed relationalmodel for databases - disconnects the schema(logical organization) of a database from thephysical storage methods.
History
1970's: Two main prototypes for relational systems weredeveloped during 1974-77. Ingres: Developed at UCB
led to Ingres Corp., Sybase, MS SQL Server, Britton-Lee,Wang's PACE.
used QUEL as query language.System R: Developed at IBM San Jose
led to IBM's SQL/DS & DB2, Oracle, HP's Allbase, Tandem'sNon-Stop SQL.
used SEQUEL (Sequential English QUEry Language) asquery language.
The term Relational Database Management System(RDBMS) is coined during this period.
History
1976: P. Chen proposed the Entity-Relationship(ER) model for database design.
Early 1980's: Commercialization of relationalsystems begins
Mid-1980's: SQL (Structured Query Language)becomes standardDB2 becomes IBM's flagship product.Development of the IBM PC gives rise to many DB
companies and products such as RIM, RBASE 5000,PARADOX, OS/2 Database Manager, Dbase III, IV(later Foxbase, even later Visual FoxPro), Watcom SQL.
History
Early 1990's: companies offering increasingly complexproducts at higher prices. development centers on client tools for application such as
PowerBuilder (Sybase), Oracle Developer, VB (Microsoft),etc.
Client-server model for computing becomes the norm forfuture business decisions.
Development of personal productivity tools such asExcel/Access (MS) and ODBC.
This also marks the beginning of Object DatabaseManagement Systems (ODBMS) prototypes.
Mid-1990's: Internet/WWW appears.Web/DB grows exponentially.
History
Late-1990's: Boom in Web/Internet/DBconnectors.Active Server Pages, Front Page, Java Servlets, JDBC,
Enterprise Java Beans, ColdFusion, Dream Weaver,Oracle Developer 2000, etc.
Open source solution come onlinewidespread use of gcc, cgi, Apache, MySQL, etc.Online Transaction processing (OLTP) and online
analytic processing (OLAP) comes of age with manymerchants using point-of-sale (POS) technology on adaily basis
History
Early 21st century: Decline of the Internetindustry as a wholesolid growth of DB applications continues.More interactive applications appear with use of PDAs,
POS transactions, consolidation of vendors, etc. Threemain (western) companies predominate in the large DBmarket: IBM (buys Informix), Microsoft, and Oracle.
Future trendsLarge data sizeMobile computing
Problems with Conventional FileSystemsData redundancy and inconsistencyDifficulty in accessing dataData isolationMultiple usersSecurity problems Integrity problems
DBMS
Characteristics:Self-containedInsulation between programs and dataData abstractionSupport of multiple views of the data
DBMS
Intended uses: Controlling redundancy Sharing of data - concurrency control Restricting unauthorized access Providing multiple interfaces Representing complex relationships among data Enforcing integrity constraints Providing backup and recovery
DBMS Advantages
Potential for enforcing standardsFlexibilityReduced application development timeAvailability of up-to-date informationEconomies of scale
Data Abstraction
Data abstraction is an abstract view of thedatabase system
Three levels of data abstractionPhysical level - how data are stored
physicallyConceptual level - what data are stored,
relationship among dataView level - which parts of data a specific
user can view
Data Models
Object-based logical data modelER modelObject-oriented model
Record-based logical data modelRelational modelNetwork modelHierarchical model
Physical data model
E-R Model
Consists of entities (objects) andrelationships among those entities
Each entity has a set of attributesdescribing it
Can be described using E-R diagram
E-R Diagram
Graphical expression of a logical structure ofa databaserectangles: represent entity sets.ellipses: represent attributes.diamonds: represent relationships among entity
sets.lines: link attributes to entity sets and entity sets
to relationships.
http://wofford.org/ecs/DataAndVisualization/ermodel/material.htm
Example of E-R Diagram
http://www.conceptdraw.com/products/img/ScreenShots/cd5/software/Chen_ERD.gif
Relational Model
Represents data and relationships withtables
Attributes are represented as columns ineach table
Each column must have a unique name
Example of Relational Database
Sirima Li3IT1
Santi Li4Math2
Anne Taylor1IT1Faculty_NameFaculty_IDDept_NameDept_ID
$2300Santi Li4$2000Sirima Li3$2500Anne Taylor1Faculty_SalaryFaculty_NameFaculty_ID
Physical Data Model
Describes data at the lowest levelDepends on physical DBMS
Technical Terms Comparison
FieldColumnAttributeRecordRowTupleEntityTableRelation
A.K.ACommonName
FormalName
Relational Operations
Query: selectUpdate: insert, update, deleteTables manipulation: create table, drop
table, alter table Index manipulation: Create index, drop
indexView manipulation: Create view, drop view
SELECT
Select a subset of tuples in a relationSELECT field(s) FROM table_nameWHERE condition
ORDER BY field(s)ExampleSELECT customer_name,credit_limit,addressFROM customer WHERE slsrep_number = 6ORDER BY credit_limit, current_balance
INSERT
Add a single tuple to a relationINSERT INTO table_name VALUESvalues to be inserted in columns
Example:INSERT INTO slsrep
VALUES (10, ‘Mark’, ‘1400 Joyce St.’,0.00, 0.05)
DELETE
Remove tuples from a relationDELETE table_name WHERE condition
ExampleDELETE customer WHERE name=‘Mark’
UPDATE
Modify attribute values of one or moreselected tuples
UPDATE table_name SET column = valueWHERE condition
ExampleUPDATE customer SET name = ‘Ann’WHERE customer_number = 100
Normalization
The process of converting a complex datastructure intosimplest structuremost stable structure
By removing redundant attributes, keys,and relationships from a conceptualdata model
1NF
First normal form (1NF) entity is achievedby removing repeating or multivaluedattributes to another, child entity.
Example
ORA
DTCASI
TOS
Cust
$6
$5$12
$10
$10$5
Prd_Price
Saw
PlierHammer
Hammer
HammerSaw
Prd_Dscr
202031006005
515
31
031006004151021006003
2010
12
021006001
Prd_QTY
Prd_ID
Order_Date
Order_ID
Example
First Normal Form
ORNDTCDTCASITOSTOS
Cust
10$5Saw2021006001
15$12Hammer1031006004$6
$5$10
$10
Prd_Price
Saw
PlierHammer
Hammer
Prd_Dscr
202031006005
53031006004151021006003
201021006001
Prd_QTY
Prd_ID
Order_Date
Order_ID
2NF
First normal form entities can be reducedto second normal form (2NF) by removingattributes that are not dependent on thewhole primary key.
Example
First Normal Form
ORNDTCDTCASITOSTOS
Cust
10$5Saw2021006001
15$12Hammer1031006004$6
$5$10
$10
Prd_Price
Saw
PlierHammer
Hammer
Prd_Dscr
202031006005
53031006004151021006003
201021006001
Prd_QTY
Prd_ID
Order_Date
Order_ID
Example
Second Normal Form
10$5Saw2021006001
15$12Hammer1031006004$6
$5$10
$10
Prd_Price
Saw
PlierHammer
Hammer
Prd_Dscr
202031006005
53031006004151021006003
201021006001
Prd_QTY
Prd_ID
Order_Date
Order_ID
ORA005DTC004ASI003TOS001
CustOrder_ID
3NF
Second normal form entities can bereduced to third normal form (3NF) byremoving attributes that depend on other,nonkey attributes (other than alternativekeys).
Example
Second Normal Form
10$5Saw2021006001
15$12Hammer1031006004$6
$5$10
$10
Prd_Price
Saw
PlierHammer
Hammer
Prd_Dscr
202031006005
53031006004151021006003
201021006001
Prd_QTY
Prd_ID
Order_Date
Order_ID
Example
Third Normal Form
102021006001
151031006004202031006005
53031006004151021006003
201021006001
Prd_QTY
Prd_IDOrder_DateOrder_ID
$5Plier3$5Saw2
Hammer
Prd_Dscr
$101
Prd_Price
Prd_ID
Denormalization
the process of attempting to optimize theperformance of a database by addingredundant data
sometimes necessary because currentDBMSs implement the relational modelpoorly
Source: www.en.wikipedia.org