29
Database Management Systems • Without databases data and programs are dependent upon each other • An input file makes no sense without the program to give it structure and meaning • Data is not self describing • Ex. 10 1011 Jones 1502 Evans ABC – What does this mean?

Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Embed Size (px)

Citation preview

Page 1: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Without databases data and programs are dependent upon each other

• An input file makes no sense without the program to give it structure and meaning

• Data is not self describing

• Ex. 10 1011 Jones 1502 Evans ABC– What does this mean?

Page 2: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Sometimes comments in program convey meaning or documentation.

• Same data element appears in many files– Data storage is wasted– Data integrity is a key concern

• If an element is updated in one file what happens to the other files??

Page 3: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Need to write programs to “recover” relationships between data elements– Ex. Personnel file and projects file. Need to

write a program to determine which people work on which project

– Time consuming and redundant

• Each programmer “owns” the data file associated with his program

Page 4: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Programmers us special/unique conventions for coding which might not be documented

• Security issues– Who is permitted to view data?– Who is permitted to change data?

• Data deletions or updates can produce inconsistencies– Dangling references

Page 5: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Terminated processes can result in data inconsistencies– Ex. A banking transaction deducts money from

one account then terminates before it can complete transfer of funds to second account.

• Physical concerns:– Adding new fields, storage devices,extra

memory.

Page 6: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Definition– A database is a self describing collection of

data elements that presents a uniform service interface

– A database management system is a software product that implements access to a database.

Page 7: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Stud ID 180-22-8787

Stud ID 180-22-8787

Stud IDStud ID 180-22-180-22-87878787

Stud Name

Perkoski, Robert

Stud Name

Robert, Perkoski

Stud Stud NameName

Perkoski, Perkoski, RobertRobert

Stud Address

1324 Williams Street , Pittsburgh, PA

Stud Address

1324 Williams St,PBGH, PA

Stud Stud Home Home AddressAddress

1500 Elm 1500 Elm Street, Street, LancasterLancaster, PA, PA

Stud Phone Number

412-673-6785

Stud Phone Number

L-673-6785

Stud Stud Local Local AddressAddress

1324 1324 Williams Williams St,PBGH, St,PBGH, PAPA

Count Field

2 Count 2 Stud Stud Home Home PhonePhone

703-678-703-678-97329732

Courses,Grades, Credits

IS010,A,3

Course, Credits

IS010,3 Stud Stud Local Local PhonePhone

672-9011672-9011

Cost 1085.00 Housing Housing FeeFee

475.00475.00

File 1(Registar) File2(St. Accts) File3(Housing)

Page 8: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Questions for Files

• What file structure for each?• Should we use codes, prefix or suffix?• How would we list class ranking of students• How often is Bob Perkoski name in file

– Is it consistent?• If Bob drops a course what gets updated?• If school changes ID # what gets updated?• An RA wants to get a list of Bob’s professors?

Page 9: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Database Models

• Definition– A set of concepts that can be used to describe

the structure of the database.• Data types

• Relationships

• Constraints

• Manipulation of the data

Page 10: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Database Models– Relational Database– Object Oriented Database Model– Deductive Database Model– Hierarchial Database Model– Network Datbase Model

Page 11: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Relational Database Model– Uses tables to organize data– Each table corresponds to an entity– Each row represents an instance of that entity– Each column represents an attribute of the

entity– Tables can be related to each other

Page 12: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems• Relational Model Example:Salespeople

Snum Sname City Comm

1001 Peel London .12

1002 Serres San Jose .13

1004 Motika London .11

Snum= unique number for each salesperson

Sname=name of salesperson

Comm = commission rate

Page 13: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Object Oriented Database Model– Represents an entity as a class

• A class captures both attributes and behavior

– Instances of the class are called objects– Within an object the class attributes take on

specific values which distinguish one object from another

– Does not restrict to native data types such as real,integer, can use other objects

Page 14: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Object Oriented Example– Class

• Cat

– Attributes• Color, weight, breed

– Behavior• Scratches, sleeps,purrs

– An instance of the cat class is an object with specific attributes

• Example – an attribute of a cat can be owner and the owner can be a student object

Page 15: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Deductive Database Model– Also known as inferential model– Stores data and elementary facts called axioms– Other facts can be derived as needed– Ex. Fact Student owns cat :stuOwnsCat(S,C)– Can deduct if two students own the same cat

and deduct new relationship:catmates.

Page 16: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Hierarchial Database Model– Relatively old, dating from 1950’s– Uses a tree structure such as a company org

chart– President –> VPresident ->Dept1-Dept2-Dept3-

>Employees– Can be translated into a linear list

Page 17: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Hierarchial Continued– Data elements organized as tabular rows– Each row for each instance of an entity– Row position implies a relationship to other

rows– Relationships represented by logical proximity

in the linearized tree

Page 18: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Hierarchial Continued• Example• President ( name = jones, phone =223-3332)

– Vice President ( name = boyd,…)• Department ( name =marketing)

– Employee ( name = Smith)– Employee(name=Jones)

• Department ( name = manufacturing)– Employee ( name = Williams)

– Vice President ( name = Graham, phone =345-6789)• Department ( name =human resources)

Page 19: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Network Database Model– Replaces the hierarchial tree with a graph

network– If employee works for two depts in previous

example the hierarchial model breaks down.– Network model maintains relationships with a

system of intersecting chains

Page 20: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

Employee Charlie

Department Electrical

Charlie works for Electrical Department

Other workers

Other departments

Charlie works for

Page 21: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

DB Designer DB User

Schema Compiler

Storage/Retrieval

Services

User Interface

Operating System

Data Dictionary Data

Page 22: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Components of DB System

• Lowest level is data and meta-data ( data that describes the data)– Cat and student example.

Store attributes of cat like color , weight

Store that Cat is name of a storage table and name of attributes

Page 23: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Conceptual Schema– App designer provides names of entities,

attributes and relationships in a machine readable script called a conceptual schema

– Ex. For the student –Cat example• Would describe the Cat table and Student Table and

how Student rows relate to Cat rows

• DBMS compiles the schema into compact form for reference by other parts of the system

Page 24: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database management Systems

• Interactive Interface– Users request services via the interface– Uniform to users– It uses the data dictionary to confirm existence

and compatibility of data lements used in the request

– The interface uses second module to process storage and retrieval requests, optimization

Page 25: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database management Systems

• Three Levels of Database Services– Physical Level

• Furthest removed from application entities

• Not always accessible to designer

• If accessible the physical schema is a machine readable script that addresses issues like location of files, buffer size, proximity of storage, file structures

Page 26: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database management Systems

• Conceptual Level– Since the storage details are isolated the

conceptual level doesn’t need to worry about it– Includes tables, objects, inference rules,

entities, relationships, constraints, and security– Physical Data Independence – the decoupling

of the application programs from the underlying hardware and data structures

Page 27: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• External Level– Different external views of the same conceptual data

– Example: some views may have all attributes of an entity while others have a subset

– External Level should adapt to changes in the conceptual schema – Logical Data Independence

• Ex. Add new attributes to an entity but old view still works

Page 28: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

Database Management Systems

• Relational Database Models

• Example:

Page 29: Database Management Systems Without databases data and programs are dependent upon each other An input file makes no sense without the program to give

SNUM SNAME City Comm

1001 Peel London .12

1002 Serres San Jose .13

1004 Motika London .11

CNUM CNAME CITY RATING SNUM

2001 Hoffman London 100 1001

2002 Giovanni Rome 200 1003

2003 Liu San Jose 200 1002

2004 Grass Berlin 300 1002

ONUM AMT ODATE CNUM SNUM

3001 18.69 10/03/00 2008 1007

3003 767.19 10/03/00 2001 1001

Salespeople

Customers

Orders