Challenges of Teaching Challenges of Teaching OO Constructs with OO Constructs with Databases Databases Shahram Ghandeharizadeh Shahram Ghandeharizadeh Database Laboratory Database Laboratory Computer Science Department Computer Science Department University of Southern California University of Southern California
43
Embed
Challenges of Teaching OO Constructs with Databases Shahram Ghandeharizadeh Database Laboratory Computer Science Department University of Southern California.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Challenges of Teaching OO Challenges of Teaching OO Constructs with DatabasesConstructs with Databases
Shahram GhandeharizadehShahram Ghandeharizadeh
Database LaboratoryDatabase LaboratoryComputer Science DepartmentComputer Science DepartmentUniversity of Southern CaliforniaUniversity of Southern California
OutlineOutline
An overview of Introductory course to An overview of Introductory course to databases.databases.
Object-oriented challenges.Object-oriented challenges. Future role of object-oriented Future role of object-oriented
constructs in data intensive constructs in data intensive applications.applications.
Database SystemsDatabase Systems
Used almost on a daily basis for either Used almost on a daily basis for either individual or business use.individual or business use.
Relational database vendors were one Relational database vendors were one of the fastest growing sectors during of the fastest growing sectors during the .COM boom!the .COM boom!
Data ModelsData Models
Build a database of all my Build a database of all my assets for licensing and assets for licensing and
royalty collectionroyalty collection
Data ModelsData ModelsConceptualConceptual
LogicalLogical
PhysicalPhysical
Relational DBMSRelational DBMS
Why?Why? Performance!Performance! Reduced application development timeReduced application development time Use of SQL makes access to data more Use of SQL makes access to data more
Make students aware of the importance Make students aware of the importance of conceptual data modeling.of conceptual data modeling.
Challenge 1Challenge 1
Make students aware of the importance Make students aware of the importance of conceptual data modeling.of conceptual data modeling.
Solution:Solution: No-one builds a house without a design.No-one builds a house without a design.
Challenge 1Challenge 1
Make students aware of the importance Make students aware of the importance of conceptual data modeling.of conceptual data modeling.
Solution:Solution: No-one builds a house without a design.No-one builds a house without a design. Michael Jackson is picky and won’t pay Michael Jackson is picky and won’t pay
for a system that does not meet his for a system that does not meet his requirements.requirements.
Relational DBMSRelational DBMS
Why?Why? Performance!Performance! Reduced application development timeReduced application development time Use of SQL makes access to data more Use of SQL makes access to data more
Reduction to tables Reduction to tables with minimal: data with minimal: data duplication, duplication, potential for data potential for data loss and update loss and update anomaliesanomalies
Effective use of a Effective use of a DBMS, DBMS, management of management of mismatch between mismatch between tables and OO tables and OO constructsconstructs
Conceptual Data ModelsConceptual Data Models
Entity-Relationship (ER) data model Entity-Relationship (ER) data model Entities, Attributes, RelationshipsEntities, Attributes, Relationships
Emp
SS#
name
address
Conceptual Data ModelsConceptual Data Models
Entity-Relationship (ER) data model Entity-Relationship (ER) data model Entities, Attributes, RelationshipsEntities, Attributes, Relationships
Enrolledin
Emp
SS#
name
address
Health Plan
name
Co-Pay
Conceptual Data ModelsConceptual Data Models
Entity-Relationship (ER) data model Entity-Relationship (ER) data model Entities, Attributes, RelationshipsEntities, Attributes, Relationships Recursive relationshipsRecursive relationships
Marriedto
Emp
SS#
name
address
Conceptual Data ModelsConceptual Data Models
Entity-Relationship (ER) data model Entity-Relationship (ER) data model Entities, Attributes, RelationshipsEntities, Attributes, Relationships Recursive relationshipsRecursive relationships
Worksfor
Emp
SS#
name
address
Conceptual Data ModelsConceptual Data Models
Entity-Relationship (ER) data model Entity-Relationship (ER) data model Entities, Attributes, RelationshipsEntities, Attributes, Relationships Recursive relationshipsRecursive relationships
Worksfor
Emp
SS#
name
address
date
Conceptual Data ModelsConceptual Data Models
Entity-Relationship (ER) data model Entity-Relationship (ER) data model Entities, Attributes, RelationshipsEntities, Attributes, Relationships Recursive relationshipsRecursive relationships InheritanceInheritance
Exercise these concepts using in-class Exercise these concepts using in-class examples and homework assignmentsexamples and homework assignments A library database contains a listing of authors who have written A library database contains a listing of authors who have written
books on various subjects (one author per book). It also contains books on various subjects (one author per book). It also contains information about libraries that carry books on various subjects.information about libraries that carry books on various subjects.
Exercise these concepts using in-class Exercise these concepts using in-class examples and homework assignmentsexamples and homework assignments A library database contains a listing of authors who have written A library database contains a listing of authors who have written
books on various subjects (one author per book). It also contains books on various subjects (one author per book). It also contains information about libraries that carry books on various subjects.information about libraries that carry books on various subjects.
Exercise these concepts using in-class Exercise these concepts using in-class examples and homework assignmentsexamples and homework assignments A library database contains a listing of authors who have written A library database contains a listing of authors who have written
books on various subjects (one author per book). It also contains books on various subjects (one author per book). It also contains information about libraries that carry books on various subjects.information about libraries that carry books on various subjects.
carry
books indexwrote subjectauthorsSS#
name
title isbn
Subjectmatter
librariesaddress
Data ModelsData Models
LogicalLogical
PhysicalPhysical
WorksforEmp
SS#nameaddress
Relational Data ModelRelational Data Model
Prevalent in today’s market place. Prevalent in today’s market place. Why? Performance!Why? Performance!
Everything is a table!Everything is a table!
Logical data design is the process of Logical data design is the process of reducing an ER diagram to a collection reducing an ER diagram to a collection of tables.of tables.
Logical Data DesignLogical Data Design
Trivial reduction:Trivial reduction: An entity set = a tableAn entity set = a table A relationship set = a tableA relationship set = a table
Pitfalls: Pitfalls: Duplication of data Duplication of data Unintentional loss of dataUnintentional loss of data Data ambiguity that impacts software Data ambiguity that impacts software
design, resulting in update anomaliesdesign, resulting in update anomalies
Data DuplicationData Duplication
Worksfor
Emp
SS#
name
address
396396 ShahramShahram SeattleSeattle
400400 AsokeAsoke ChicagoChicago
200200 JoeJoe New YorkNew York
396396 400400
200200 400400
120120 400400
SS#SS# NameName AddressAddress SS#SS# MGRMGR
SS#SS#
Data DuplicationData Duplication
The SS# column is duplicated!The SS# column is duplicated!
Worksfor
Emp
SS#
name
address
396396 ShahramShahram SeattleSeattle
400400 AsokeAsoke ChicagoChicago
200200 JoeJoe New YorkNew York
396396 400400
200200 400400
120120 400400
SS#SS# NameName AddressAddress SS#SS# MGRMGR
SS#SS#
Data Duplication: SolutionData Duplication: Solution Merge the two tables into one:Merge the two tables into one:
396396 ShahramShahram SeattleSeattle 400400
400400 AsokeAsoke ChicagoChicago NULLNULL
200200 JoeJoe New YorkNew York 400400
SS#SS# NameName AddressAddress MGRMGR
SS#SS#
Worksfor
Emp
SS#
name
address
Data LossData Loss
Ford maintains warehouses containing Ford maintains warehouses containing different automobile partsdifferent automobile parts
Records are inserted and deleted Records are inserted and deleted based on availability of a part at a based on availability of a part at a warehousewarehouse
Represent faculty of a department as:Represent faculty of a department as:
A change of address for a faculty might A change of address for a faculty might be for the entire department. This be for the entire department. This cannot be differentiated with this table cannot be differentiated with this table design!design!
Employees of a bi-lingual company Employees of a bi-lingual company having different skills.having different skills.
Update anomalies!Update anomalies!
AsokeAsoke TeachTeach HindiHindi
AsokeAsoke CookCook FrenchFrench
AsokeAsoke NullNull GermanGerman
AsokeAsoke ProgramProgram EnglishEnglish
EmployeeEmployee SkillSkill LanguageLanguage
Data Ambiguity: SolutionData Ambiguity: Solution
Utilize two tables:Utilize two tables:
AsokeAsoke TeachTeach
AsokeAsoke CookCook
AsokeAsoke ProgramProgram
EmployeeEmployee SkillSkillAsokeAsoke HindiHindi
AsokeAsoke FrenchFrench
AsokeAsoke GermanGerman
AsokeAsoke EnglishEnglish
EmployeeEmployee LanguageLanguage
Logical Data DesignLogical Data Design
A quest to flatten objects with minimal A quest to flatten objects with minimal data duplication, loss of data, and data duplication, loss of data, and update anomalies!update anomalies!
William Kent, “A Simple Guide to Five William Kent, “A Simple Guide to Five Normal Forms in Relational Database Normal Forms in Relational Database Theory”, Communications of the ACM Theory”, Communications of the ACM 26(2), Feb 1983, 120-125.26(2), Feb 1983, 120-125.
Data ModelsData Models
PhysicalPhysical
WorksforEmp
SS#nameaddress
Logical Data DesignLogical Data Design
396396 ShahramShahram SeattleSeattle 400400
400400 AsokeAsoke ChicagoChicago NullNull
SS#SS# NameName AddressAddress MGR SS#MGR SS#
Physical ImplementationPhysical Implementation
Reconstruct main memory objects for Reconstruct main memory objects for manipulation and presentation:manipulation and presentation: Specify class definitionsSpecify class definitions
Typically correspond to entity-setsTypically correspond to entity-sets
Populate an instance of a class by issuing Populate an instance of a class by issuing SQL queries to a DBMSSQL queries to a DBMS
Update instances in memoryUpdate instances in memory Flush dirty instances back to DBMSFlush dirty instances back to DBMS
Potential use of transactionsPotential use of transactions
Type MismatchType Mismatch
A column of a row must be a primitive A column of a row must be a primitive such as an integer, real, etc.such as an integer, real, etc. It may NOT be an array of integers or It may NOT be an array of integers or
object pointersobject pointers
A property (attribute) of a class might A property (attribute) of a class might be of a multi-valued type, e.g., an array, be of a multi-valued type, e.g., an array, a vector, etc.a vector, etc.
Changes in software may impact the Changes in software may impact the design of tables. (Management of type design of tables. (Management of type mismatch by the system designer.)mismatch by the system designer.)
ImplementationImplementation
Set operators in the DBMSSet operators in the DBMS Does set A contain set B?Does set A contain set B? Does value v1 appear in set A?Does value v1 appear in set A?
Aggregates in the DBMSAggregates in the DBMS Compute average employee salaryCompute average employee salary Count the number of employeesCount the number of employees Find the oldest employeeFind the oldest employee
Reduction to tables Reduction to tables with minimal: data with minimal: data duplication, duplication, potential for data potential for data loss and update loss and update anomaliesanomalies
Effective use of a Effective use of a DBMS, DBMS, management of management of mismatch between mismatch between tables and OO tables and OO constructsconstructs
A Shift in ComputingA Shift in Computing
1985-20001985-2000 1999+1999+Server-centricServer-centric DistributedDistributedDumb clientsDumb clients Smart clientsSmart clientsHardware-drivenHardware-driven Software-drivenSoftware-drivenUser to appUser to app User to app; app to appUser to app; app to appInformation accessInformation access Information actionInformation actionOne-wayOne-way Two-wayTwo-wayMonolithic islandsMonolithic islands peer-to-peerpeer-to-peerIntegration an afterthoughtIntegration an afterthought Integration by designIntegration by designChallenge: scaleChallenge: scale Challenge: valueChallenge: value
InternetInternet
Future VisionFuture Vision In the future, any two IT components will In the future, any two IT components will
automatically integrate and “communicate” with automatically integrate and “communicate” with one another, one another, eveneven though they were not though they were not specifically designed to interoperatespecifically designed to interoperate
How?How? SemanticsSemantics StandardsStandards Concept of “software and data” as a service, web Concept of “software and data” as a service, web
service, e.g.,service, e.g., Google as a web serviceGoogle as a web service Microsoft Teraserver web servicesMicrosoft Teraserver web services Experian (TRW) credit report web servicesExperian (TRW) credit report web services Etc.Etc.
XMLXML A standard for data interoperability among web A standard for data interoperability among web
servicesservices Language independentLanguage independent
.NET.NET SQL 2000SQL 2000 Commerce serverCommerce server Windows 2000Windows 2000
Future ChallengeFuture Challenge
Educate students to see Internet as an Educate students to see Internet as an object-oriented software platform!object-oriented software platform!
Software at an Internet scale must be:Software at an Internet scale must be: Robust: Physical location independenceRobust: Physical location independence Ensure availability of data and Ensure availability of data and
functionality at all timesfunctionality at all times Modular and ExtendibleModular and Extendible Integrate with other software componentsIntegrate with other software components