Chap 1 Intro To DB

Published on October 2021 | Categories: Documents | Downloads: 1 | Comments: 0 | Views: 58
of x
Download PDF   Embed   Report

Comments

Content

 

Wee eek k 3: Intr Introdu oducti ction on to Data atabase bases s • The database is the underlying framework of the information system. • Relational Database Management Systems (DBMSs) is the predominant system for business applications at present.

MIS T811: Week 3

1

3.1 3. 1 Intr ntrodu oducti ction on • A database is a collection of related data. • The Da Database tabase Management Sys tem (DBMS) is the software that manages and controls access to the database. • A databa database se appli cation is a program that interacts with the database at some point of its execution. • The database system is a collection of application programs that interact with the database along with the DBMS and the database itself. • Mor More e accu accurat rate e defi definiti nitions ons will will be pr provi ovided ded la later ter.. MIS T811: Week 3

2

1  

Examples • Purcha Purchases ses fro from mas supe uperma rmarke rkett  – Bar code reader to scan scan each purchase. purchase.  – Bar code reader is linked to an application program program that uses the bar code to find out the price of the item from a product database.  – This program reduces reduces the number of such such items in stock and displays the price on the cash register.  – If the reorder level falls below a specified threshold threshold,, the database system may automatically place an order to obtain more stocks of that item.

MIS T811: Week 3

3

Examples ctd ctd… … • Pur Purcha chases ses usin using gy your our cre credit dit car card d  – Assistant normally checks you have sufficient sufficient credit left to make the purchase. This can be done on the telephone t elephone or may be done automatically by a card reader linked to a computer system.  – There is a database somewhere that contains contains information about the purchases you have made on your credit card.  – To check your credit there is a database application application program that uses your credit card number to check that t hat the price of the goods you wish to buy together with the sum of the purchases you have already made this billing period is within your credit limit. MIS T811: Week 3

4

2  

Credit Cre dit card exa exampl mple e ctd…  – After confirmation of the purchase the details of the purchase are added to this database.  – The application program also accesses the database to check that the credit card is not on a list of stolen credit credit cards befo before re author authorising ising the purchase.  – There are other application programs to send out monthly statements to each credit card holder and to credit accounts when payment is received.

MIS T811: Week 3

5

Examples ctd ctd… … • Boo Bookin king gah holi oliday day u using sing a tr travel avel age agency ncy  – When you make en enquiries quiries about a h holiday, oliday, the travel agent agent may access several databases containing holiday and flight details.  – When you book the h holiday, oliday, the databa database se system has to make all the necessary booking arrangements. arrangements. • The system has to ensure that two different different agents agents do not book the same holiday or overbook the seats on a flight.

 – The travel agent may may have another another,, usually separate, database for invoicing.

MIS T811: Week 3

6

3  

3.2 3. 2T Tradi raditi tion onal al FileFile-Based Based Systems • The file-based file-based system system is the predecesso predecessorr of the database system. • This This approa approach ch is mostl mostly y obsole obsolete te bu but: t:  – understanding the problems problems inherent in file file-based systems may prevent us from repeating these problems in our database systems,  – understanding how the the file syst system em works iis s extremely useful when converting a file-based system to a database system. MIS T811: Week 3

7

3.2.1 File-Based Approach DEFN: The File-based system is a collection of application programs that perform services for the end-users such as the production of reports. Each program defines and manages its own data. • The These se wer were ea an ne earl arly ya attem ttempt pt to c comp ompute uteris rise e the manual filing system that most of us are familiar with. • Rea Really lly o only nly wo works rks we wellll wh when en the numb number er of it items ems to be stored is small. • It wor works ks ade adequa quately tely w when hen tther here e are la large rge n numb umbers ers and we have only to store and retrieve them. MIS T811: Week 3

8

4  

When does the manual manual ffili iling ng system break brea kd down? own? • The manua manuall fi filing ling syst system em br breaks eaks down when we have to cross-reference or process information in the files. Example:  A typical real estate agent’s Example: A agent’s office might have a separate file for each property for sale or rent, each potential buyer and renter, and each member of staff. MIS T811: Week 3

9

Real Re al Estate Exa Examp mple le ct ctd… d… How easy would it be to answer these questions using this set up? •

What three three-be -bedroo droom m pro proper perties ties do y you ou hav have e for sale sale with a gard garden en and garage?



What flats do y you ou h have ave for ren rentt with within in th three ree kilometre kilometres s of the the city city centre?



What is th the e averag average e re rent nt for for a two-bedro two-bedroom om fflat? lat?



What is tthe he total total annua annuall salary salary bill for staff staff? ?



How does does last m month onth’s ’s turn turnover over comp compare are wi with th the projec projected ted figure figure for this month?



What is is the e expec xpected ted month monthly ly tur turnove noverr for next financ financial ial year? year?

MIS T811: Week 3

10

5  

Real Re al Estate Exa Examp mple le ct ctd… d… • The fil ee-based based syst em was developed in response to the needs of industry for more efficient efficie nt data access. A decen decentralise tralised d approach approach was taken, where each department, with the assistance of Da Data ta Process Processing ing (DP) staff, stored and controlled its own data. • We w will ill ill illust ustrate rate thi this s us using ing the DreamHome example which will be outlined on the following slides. MIS T811: Week 3

11

Drea reamH mHome ome Example • The Sales Depar Department tment is respo responsibl nsible e for selling and renting property. • The fform orm tthat hat la landl ndlord ord h has as to ffill ill out out before property is marketed for rent is given on next slide.  – This gives de details tails of rental rental property as as well as owner (landlord) details. MIS T811: Week 3

12

6  

Figure Figu re 3. 3.1 1  –

Sales Department

 –

forms:

 –

(a) Property for

 –

Rent Details form

MIS T811: Week 3

13

Drea reamHome mHome Example ctd…  –

- Sales Department

 –

also handles enquiries from clients (renters) ←

Figur e 3 3.1 .1 ct d

(b) Client Details form. MIS T811: Week 3

14

7  

Drea reamHome mHome Example ctd… • Wi With th as assi sist stan ance ce of Da Data ta Processi ng (DP) Department, Sales Department creates an information system to handle renting the property  – This consists of three files containing prop property, erty, owner, and client details (see next slide)  – For simplicity details relating to staff members, branch offices and business owners are omitted.

MIS T811: Week 3

15

Figure 3.2 Sales files used PropertyForRent

PrivateOwner 

MIS T811: Week 3

16

8  

Figure 3.2 Sales files used ctd PrivateOwner 

Client

MIS T811: Week 3

17

Drea reamHome mHome Example ctd… • Contract Contracts s Departm Department ent is is respons responsible ible for rental agreements. • Wheneve Wheneverr a client client agree agrees s to rent a property a form is filled out by one of the Sales staff (see next slide) which is passed to the Contracts Department which allocates a lease number and completes the payment and rental period details. MIS T811: Week 3

18

9  

Figure Figu re 3. 3.3 3  –

Lease

 –

Details

 –

form

 –

used by

 –

Contracts

 –

Dep’t.

MIS T811: Week 3

19

Drea reamHome mHome Example ctd… • With assistan assistance ce from from the the Data Data Proces Processing sing (DP) Department the Contracts Department creates an information system to handle lease agreements.  – This consists of three ffiles iles containing lease, property, and client details (see next slide)  – The data is similar to that held by the Sales Department. MIS T811: Week 3

20

10  

Figure Figu re 3. 3.4 4 Lease file

PropertyFo Prope rtyForRent rRent file

MIS T811: Week 3

21

Figure Figu re 3. 3.4 4 ctd Client file

Lease file

MIS T811: Week 3

22

11  

Dre rea amHome Example ctd • Figur e 3. 3.5 5 illustrates the situation. • Eac Each h dep departm artment ent a acces ccesses ses thei theirr own ffile iles s through applications programs written specially for them. • Eac Each h set of ap appli plicati cation on pro progra grams ms han handle dles s data entry, file maintenance, and the generation of a fixed set of specific reports. • The p physi hysical cal s struc tructure ture a and nd st storag orage e of the the data files and records are defined in the application code. MIS T811: Week 3

23

Figure 3.5 File-based processing

Sales Files PropertForRent (prope (propertyNo, rtyNo, street, city, postcode, type, rooms, rent, ownerNo) PrivateOwner (ownerNo, PrivateOwner  (ownerNo, fName, lName, address, telNo) Client (clientNo, fName, lName, address, telNo, prefType, maxRent) MIS T811: Week 3

24

12  

Figure Figu re 3. 3.5 5 ctd

Contract Files  – Lease (leaseNo, propertyNo, clientNo, rent, paymentMethod, deposit, paid, rentStart, rentFinish, duration)  – PropertyForRent (proper (propertyNo, tyNo, street, city, postcode, rent)  – Client (clientNo, fName, lName, address, telNo) MIS T811: Week 3

25

Dre rea amHome Example ctd • The There re is a sig signif nifica icant nt amoun amountt of duplication of data in the two departments. • This duplic duplication ation of d data ata iis s ge general nerally ly true of file-based systems.

MIS T811: Week 3

26

13  

Termi Te rminol nology ogy u used sed in fil filee-base based d systems  A file is simply simply a collection of records records,, which contain log logically ically relate related d data data.. Each record contains a logically connected set of one or more fields fields,, where each field represents some characteristics of the real-world object that is being modelled. MIS T811: Week 3

27

3.2.2 Limitations of the File-Based  Ap  A p p r o ac ach h Sepa eparation ration and is isolation olation of data • It is more d diffi ifficult cult to ac access cess data that should be available when the data is isolated in separate files. • The d diff ifficu iculty lty iis s com compou pounde nded d if we required data from more than two files. MIS T811: Week 3

28

14  

Limitations Limi tations of filefile-base based d syst syste ems ctd Duplication of data

Uncontrolled duplication of data is undesirable • It is w waste asteful ful.. It cos costs ts time time an and d money money to enter enter the data more than once. • It tak takes es up a addi dditio tional nal s stora torage ge sp space ace whic which h has costs attached. Often duplication can be avoided by sharing files. • Dup Duplic licati ation on can llead ead to lloss oss of da data ta in integr tegrity; ity; the the data is no longer consistent. MIS T811: Week 3

29

Limitations Limi tations of filefile-base based d syst syste ems ctd Data Da ta d dependence ependence • The physi physical cal struc structure ture and s storage torage of the data files and records are defined in the application code. Making changes to an existing structure is difficult.

MIS T811: Week 3

30

15  

Limitations Limi tations of filefile-base based d syst syste ems ctd Incompatible file formats

• The stru structu cture re of ffile iles s is embe embedded dded in th the e applications program. The structures are dependent on the application programming language.  – Example: The structure of a file generated by a COBOL program may be different from the structure of a file generated generated by a `C’ program. The direct incompatability of such files makes them difficult to process jointly. They need to be converted to some common format to facilitate processing. MIS T811: Week 3

31

Limitations Limi tations of filefile-base based d syst syste ems ctd Fixed queries/prol queries/prolifera iferation tion of application programs • File-base File-based d syste systems ms are are very dependen dependentt upon the application developer, who has to write any queries or reports that are required. • For som some e orga organis nisati ations ons the query query or repo report rt that could be produced was fixed. MIS T811: Week 3

32

16  

Limitations Limi tations of filefile-base based d syst syste ems ctd • In oth other er o org rgan anis isat atio ions ns ther there e was was a proliferation of files and application programs.  – Eventually the DP Department with its current resources could not handle all the work.  – The pressure put on DP staff result resulted ed in programs that were inadequate or inefficient in meeting the demand of the users, had limited documentation, and maintenance that was difficult. MIS T811: Week 3

33

Limitations Limi tations of filefile-base based d syst syste ems ctd  – Certain types of data functionality functionality were often sacrificed: • no prev prevision ision for secu security rity or iintegrity ntegrity,, • In the eve event nt of hardw hardware are or softw software are fail failure ure recovery was limited or non-existent, • no provi provision sion for s shared hared access, access, acc access ess to files was restricted to one user at a time.

MIS T811: Week 3

34

17  

3.3 Database Approach •

The The limi limita tati tion ons s of th the e file file-b -bas ased ed appr approa oach ch can be attributed to two factors: 1. The defi definitio nition n of the data is e embed mbedded ded in tthe he applications program, rather than being stored separately and independently; 2. The There re is no co contr ntrol ol o over ver tthe he ac acce cess ss and and manipulation of data beyond that imposed by the applications programs.

MIS T811: Week 3

35

The database • The database and the Database Management System (DBMS) were developed to overcome these limitations.

DEFN: The database is a shared collection of logically related data, and a description of this data, designed to meet the information needs of an organisation. • The da databa tabase se is a sin single gle,, poss possibl ibly y larg large, e, rep reposi ositor tory y of data that can be used simultaneously by many departments and users, All data items are integrated with a minimum amount of duplication. MIS T811: Week 3

36

18  

The database database ct ctd d • The d datab atabase ase iis s a sha shared red c corp orpora orate te re resou source rce.. • The d datab atabase ase h hold olds s not on only ly the o orga rganis nisatio ation’s n’s operational data but also a description of the data. For this reason, a database is also defined as a selfdescribing collection of integrated records. records. The description of the data is known as the system catalog (or data dicti onary or metadata – the `data about the data’). It is the self-describing nature of a database that provides program-data independence.. independence

MIS T811: Week 3

37

The database database ct ctd d • The da databa tabase se app approa roach ch sep separa arates tes the s struc tructur ture e of the data from the application programs and stores it in the database. If the new data structures are added or existing structures are modified then the application programs are unaffected, provided they do not directly depend upon what has been modified.  – If we add a new field o orr record or create a new file, existing applications are unaffected.  – If we remove a field from a file that an application application program uses, then that application program is affected by this change and must be modified accordingly accordingly.. MIS T811: Week 3

38

19  

Some more definitio definitions ns • An entity is a distinct object (a ( a person, place, thing, concept, or event) in the organisation that is to represented represented in the database. • An attribute is a property that describes some aspect of the object that we wish to record. • A relationship is an association between entities. MIS T811: Week 3

39

Drea reamHome mHome Case Stud tudy y • Figur Figure e 3.6 Exam Example ple E Entity ntity Relat Relationsh ionship ip (E (ER) R) Dia Diagram gram for part of the DreamHome

MIS T811: Week 3

40

20  

Dre rea amHome Case S Study tudy ctd Figure 3.6 consists of: • Six e enti ntitie ties s (re (rectan ctangle gles): s): B Bran ranch, ch, S Staff taff,, PropertyForRent, Client, PrivateOwner, and Lease; • Sev Seven en rel relatio ationsh nships ips (t (the he nam names es ad adjac jacent ent to th the e lines): Has, Offers, Oversees, Views, Owns, LeasedBy, and Holds; • Six a attri ttribute butes, s, one ffor or eac each h enti entity: ty: branc branchNo hNo,, staffNo, propertyNo, clientNo, ownerNo, and leaseNo. MIS T811: Week 3

41

Dre rea amHome Case S Study tudy ctd • The datab database ase repres represents ents the entit entities, ies, the attributes, and the logical relationships between the entities. That is, the database holds data that is logically related.

MIS T811: Week 3

42

21  

3.3.2 The Database Management System Syst em (DBMS (DBMS)) DEFN: The Database Management System (DBMS (DBMS)) is a software system that enables users to define, create, maintain, and control access to the database. • The DBM DBMS S is tthe he s soft oftwar ware e th that at interacts inter acts wi with th the users users’’ appli applicatio cation n programs and the database. MIS T811: Week 3

43

DBMS ct ctd d  A DBMS usually provides provides the following facilities • It a allows llows users to d define efine the d databa atabase, se, usually through a Data Definition Language (DDL). The DDL allows users to specify the data types and structures and the constraints on the data to be stored in the database. MIS T811: Week 3

44

22  

DBMS ct ctd d • It allows allows u users sers to to insert, insert, updat update, e, delete, delete, and retrieve data from the database, usually through a Da Data ta Manip Manipulatio ulation n Language L anguage (DML). Having a central repository for all data and data descriptions allows the DML to provide a general inquiry facility to this data, called a query language. language. The most common query language is the Structured Query Que ry Language (SQL). MIS T811: Week 3

45

DBMS ct ctd d • It pr provide ovides s ac access cess to th the e dat database abase.. It may provide  – A security s system ystem which prevents unauthorized users accessing the database;  – An integrity system which maintains consistency of stored data;

MIS T811: Week 3

46

23  

DBMS ct ctd d  – A concurre concurrency ncy system which allows shared access to the database;  – A recovery system which restores the the database to a previous consistent state following a hardware or software failure;  – A user-acc user-accessible essible catalogue catalogue which contains descriptions of the data in the database. MIS T811: Week 3

47

DBMS ct ctd d DEFN: The The A  Ap p p li c ati at i o n Pr Pro o g r am is a computer program that interacts with the database by issuing an appropriate request (typically an SQL statement) to the DBMS. • Use Users rs in intera teract ct wi with th th the e dat databa abase se th throug rough ha number of applica application tion programs that are used to create and maintain the database and to generate information. The application programs may be written in some programming language or in some higher-level fourth-generation language. MIS T811: Week 3

48

24  

Figure Figu re 3. 3.7 7

© Pearson Education Education Limited Limited 1995, 2 2005 005 MIS T811: Week 3

49

Views DEFN: A DEFN:  A view is some subset of the database. It allows see it. users to see the data the way they want to Benefits of views: • Provide Provide a level of se securit curity. y. C Can an ex exclud clude e data that some users should not see. • Provid Provide e a mechan mechanism ism tto o cus custom tomize ize tthe he appearance of the database, • Can prese present nt a cons consiste istent, nt, uncha unchanging nging pict picture ure of the structure of the database even if the underlying database is changed. MIS T811: Week 3

50

25  

3.3. 3. 3.4 4C Com ompo ponent nents so off the t he DBMS Environment • The There re are ffive ive m majo ajorr com compon ponent ents: s: hardware,, software hardware software,, data data,, procedures,, and people procedures people..

MIS T811: Week 3

51

Hardware • Needed Needed for for DBMS DBMS and the appli applicatio cations ns to run on. • Can range range from a single single of p perso ersonal nal compu computer, ter, to to a single single mainframe, to a network computers. • Depends Depends on on the organ organizat ization’ ion’s s requ requireme irements nts and and the DBMS DBMS used. • A DBMS DBMS requir requires es a minimum minimum amoun amountt of main main memory memory and and disk space to run, but this minimum may not give acceptable performance. • The frontend is the part of the DBMS that interfaces with the user. This is called client-server  client-server architecture: architecture: the backend is the server and the frontends are the clients.

MIS T811: Week 3

52

26  

Software • Made Made up of of DBMS DBMS softwa software re and and th the e application programs, together with operating system, including network software if the DBMS is being used over a network. • Applicat Application ion p progra rograms ms may be written written usin using g a fourth-generation language like SQL embedded in a third generation language. MIS T811: Week 3

53

Data • Fr From om tthe he e endnd-us users ers’’ po poin intt of vi view ew d data ata is the the most important component of the DBMS environment. • Dat Data a is tthe he bridg bridge e bet betwee ween n the mac machin hine e components and human components. • The d datab atabase ase co conta ntains ins bo both th the op operat eration ional al dat data a and the metadata (“data about data”). • The s struc tructure ture o off the da datab tabase ase iis s cal called led the the schema.. schema MIS T811: Week 3

54

27  

Data ctd • Figur e 3. 3.7 7 on earlier slide is a schema consisting of four files (or tables): PropertyForRent, PrivateOwner, Client, Lease.  – PropertyForRent table has 8 fields or attributes: propertyNo, street, city, postcode, type (the property type), rooms (the number of rooms), rent (the monthly rent), ownerNo.  – ownerNo attribute models the relationship between PropertyFo Prope rtyForRent rRent and Pr Private ivateOwner Owner (the ow owner ner Own Owns s the property for rent), see Figure 3.6.

MIS T811: Week 3

55

Procedures • Pro Proced cedure ures s are in instr structi uctions ons an and d rule rules s that go gover vern n the design and use of the database. • Docu Document mented ed pr proce ocedur dures es on h how ow to ru run n the sy system stem are required by the users of the system and the staff that manage the database. •

Proced Procedure ures s ma may y co consi nsist st o off in instru structio ctions ns on how to:  – log on to the DBMS;  – use a particular DBMS facility or application program;  – start and stop the DBMS;  – change the structure of a table. MIS T811: Week 3

56

28  

People • There are ffour our d disti istinct nct types of p people eople:: data and database administrators, database designers, application developers, and end-users.

MIS T811: Week 3

57

Data Da ta and Da Databa tabase se Adm Admini inistr strators ators  – They deal with the management and c control ontrol of a DBMS and its data.  – The Data Administrator (DA) is responsible ffor or the management of the data resource including database planning, development and maintenance of standards, policies and procedures, and conceptual/logical database design. This person consults with and advises senior managers so that the database development will support corporate objectives. MIS T811: Week 3

58

29  

Data Da ta and Da Databa tabase se Adm Admini inistr stra ator tors s ctd…  – The Database Administrator (DBA) is responsible for the physical realization of the database, including physical database design and implementation, security and integrity control, maintenance of the operational system, and ensuring satisfactory performance of the application for users. This person is more technical than DA.  – Some organizations have one pers person on performing both roles. MIS T811: Week 3

59

Database Da tabase Desig Designers ners • Large Large databa database se design design projects projects have have two types of designer   – Logical database designer: designer: identifies the data (the entities and attributes), the relationships between the data, and the constraints on the data that is to be stored in the database.  – Physical database database designer: deci decides des how the logical database design is to be physically realized. MIS T811: Week 3

60

30  

 Ap  A p p l i c at atii o n Dev Devel elo o p ers er s • People People who implement implement the applicati application on programs that provide the required functionality for the end-users. • Usually Usually appli applicatio cation n develop developers ers work work from from a specification produced by systems analysts. • Each program program contains contains statemen statements ts that request the DBMS to perform some operations on the database including retrieving data, inserting, updating, and deleting data. MIS T811: Week 3

61

End-Users • End End-us -users ers are the “cl “clien ients” ts” for the data databas base, e, w whic hich h has been designed and is being maintained to serveand theirimplemented, information needs. • End End-us -users ers ca can n be cl classi assifie fied d acco accordi rding ng to th the e way they use the database system:  – Naïve users: access database through specially written application programs that attempt to make the operations as simple as possible.  – Sophisticated users: knows the structure of the database and facilities offered by the DBMS. May use a high-level query language like SQL to perform the required operations or may even write application program programs s for their own use. MIS T811: Week 3

62

31  

3.4 3. 4H His isto tory ry of Da Database tabase Ma Management nagement Systems • Fir Firstst-gen genera eratio tion n (mi (mid d 196 1960’s 0’s))  – Hierarchical Hierarchical model (e.g. Information Management System) and network model by IDS (Integrated Data Store).

• Se Seco cond nd-g -gen ener erat atio ion n  – Relational model proposed by E.F. Codd Codd in 1970. SQL is the standard language language for for relational DBMSs. DBMSs.

• Th Thir irdd-ge gene nera rati tion on  – Object-Oriented  – Object-Relationa Object-Relationall MIS T811: Week 3

63

3.5. 3. 5.1 1 Adv Advant antages ages of DBMS DBMSs s • Co Contr ntrol ol o off da data ta rred edun unda danc ncy y • Da Data ta c con onsi sist sten ency cy • Mor More e inf inform ormati ation on fr from om th the e sam same e amo amount unt o off dat data a • Sh Shar arin ing go off d dat ata a • Im Impr prov oved ed da data ta inte integr grit ity y • Im Impr prov oved ed se secu curi rity ty • En Enfo forc rcem emen entt o off s sta tand ndar ards ds • Ec Econ onom omy yo off s sca cale le MIS T811: Week 3

64

32  

3.5. 3. 5.1 1 Adv Advanta antages ges of DBM DBMS Ss ctd • Balan Balance ce of confli conflicti cting ng requir requireme ements nts • Improv Improved ed data data acces accessib sibili ility ty and and responsiveness • Incr Increa ease sed d pr prod oduc ucti tivi vity ty • Improved Improved maintenan maintenance ce through through data independence • Incr Increa ease sed d concu concurr rren ency cy • Improved Improved backup backup and and reco recovery very services services MIS T811: Week 3

65

3.5. 3. 5.2 2D Dis isadvan advantag tages es of DBMS DBMSs s • Complexity • Size • Cos Cost of of D DB BMSs MSs • Addit Addition ional al hardwa hardware re costs costs • Cost Cost of co conv nver ersi sion on • Perfo rforma rmance nce • High High impa impact ct of fa faililur ure e MIS T811: Week 3

66

33  

3.6 3. 6T The he Re Relat latio ional nal Mod Model el • The Re Relat lation ional al Dat Databa abase se Man Manage agemen mentt Syst System em (RDBMS RDBMS)) is the dominant data-processing software used today. • Thi This s so softw ftware are iis s the sec second ond gen genera eratio tion n of D DBMS BMSs s and is based on the relational mo model del of E.F. Codd (1970). • Cod Codd d was ttrain rained ed as a ma mathe themat matici ician. an. S Set et th theor eory y an and d predicate logic mainly underpin his model. • In th the e rel relation ational al mo model, del, all d data ata iis s log logically ically struc structured tured within relations (tables). • Each relation has a name and is made up of named attributes (columns) of data. • Each tuple (row) contains one value per attribute. MIS T811: Week 3

67

3.6. 3. 6.1 1T Termi ermino nolo logy gy Relation: A Relation:  A relation is a table with columns and rows.  At tr i bu te:  An attribute is a named column of a relation. Domain: A Domain:  A domain is the set of allowable values for one or more attributes. Tuple: A Tuple:  A tuple is a row of a relation. Degree: The degree of a relation is the number of attributes it contains. Cardinality: The cardinality of a relation is the number of tuples tuple s it cont contains. ains. Relation Re lation al database database::  A collection of normalized* relations with distinct relation names. *(More on this in a later lecture.) l ecture.) MIS T811: Week 3

68

34  

 All t er  A ern n at atii v e tter erm minology Formal terms

 All t ernat  A er nat i v e 1

 Alt  A lt er ern n at ativ iv e 2

Relation

Table

File

Tuple

Row

Record

 Attribute

Column

Field

MIS T811: Week 3

69

3.6. 3. 6.2 2R Relati elation onal al Keys Superkey:  An attribute, or set of attributes, that Superkey: An uniquely unique ly identi identifies fies a tuple withi within n a relation. relation. Candid Ca ndid ate key: key: A  A superkey such that no proper subset is is a superk superkey ey withi within n the rela relation. tion. Primary key: The candidate key that is selected to identify identi fy tuples uniqu uniquely ely within the rel relation. ation. Foreign key: An key:  An attribute, or set of attributes, within one relation that matches the candidate key of some (possibly the same) relation. MIS T811: Week 3

70

35  

Representing Relational Database Schemas • The c comm ommon on co conven nventio tion n is to g give ive the the name name of the relation followed by the attribute names in parenthesis. The primary key is usually underlined. (Q2 of the tutorial exercises provides an example.) • The c conce onceptu ptual al mo model del,, or conc conceptu eptual al schem schema, a, is the set of all such schemas for the database. (Q2 of the tutorial exercises provides an example.) MIS T811: Week 3

71

Integrity Constr onstra aints Null: Represents a value for an attribute that is currently unknown or is not applicable for this tuple. Base relation relation :  A named relation corresponding to an entity in the conceptual schema, whose tuples are physi physically cally sto stored red in the database. database. Entit y Integrity: In a base relation, no attribute of the primary key can be null. Referential Re ferential Integrit y: If a foreign key exists in a relation, either the foreign key value must match a candidate candidate key valu value e of some tuple in its home relation or the foreign key must be wholly null. MIS T811: Week 3

72

36  

3.6.3 Views View: The dynamic result of one or more relational operations operating on the base relations to produce another relation. A view is a virtual relation that does not necessarily exist in the database but can be produced upon request by a particular user, at the time of request. • Views provi provide de a powe powerful rful and flexib flexible le s securit ecurity y mechanism by hiding parts of the database from certain users. • Views permit users to ac access cess data in a way that is customised custo mised to their n needs eeds.. • Views can simpl simplify ify c comple omplex x op operatio erations ns o on n th the e base base relations. MIS T811: Week 3

73

Tutorial Tutori al E Exercis xercises es for Week 3 • Th The eW Wel ellm lmea eado dows ws Ho Hosp spit ital al Ca Case se Study is from DATABASE SYSTEMS  A Practical Approach to Design, Implementation, and Management., Thomas Connolly & Carolyn Begg (2005), pp. 1260-1267, A 1260-1267, Ad ddison Wesley.. Wesley • This will be h handed anded out iin n the lectu lecture. re. MIS T811: Week 3

74

37  

Tutorial Tutor ial Exercis Exercises es Wee Week k 3 ctd… ct d… 1.

Stu Study dy the We Well llme mead adow ows s Hos Hospi pital tal Ca Case se St Stud udy y hand out.

a) How wou would ld a ffil ile eb base ased da app ppro roac ach hb be e implemented? b) In wh what at wa ways ys woul would d a DBM DBMS Sh hel elp p tthi his s organisation? c)

What What da data ta c can an y you ou iide dent ntify ify that that n nee eeds ds tto o be represented in the database?

d) Wha Whatt re relati lations onship hips s ex exist ist between between the dat data a it items? ems? MIS T811: Week 3

75

Tutorial Tutor ial Exercis Exercises es Wee Week k 3 ctd… ct d… 2. The following tables form part of a database held in a relational DBMS: Hotel

(hotelNo, hotelName, city)

Room

(roomNo, hotelNo, type, price)

Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) Guest

(guestNo, guestName, guestAddress)

where •

Hotel contains hotel details details and hotelNo is the primary key;



Room contains room details for each hotel and (roomNo,hotelNo) forms the primary key;



Booking contains details of bookings and (hotelNo,guestNo,dateFrom) forms the primary key;



Guest contains guest guest details and guestNo is the primary key. MIS T811: Week 3

76

38  

Tutorial Tutor ial Exercis Exercises es Wee Week k 3 ctd… ct d… a) Iden Identify tify the for foreig eign n ke keys ys iin n this this sc schem hema. a. E Expl xplain ain how the entity and referential integrity rules apply to these relations. b)

Pr Prod oduce uce so some me s sam ampl ple e ta tabl bles es ffor or tthe hese se rrel elati ation ons s that observe the relational integrity rules. Suggest some general constraints that would be appropriate for this schema.

HOMEWORK: Submit answers to 1a) 1b), 1c), 1d), 2a), 2b) to ERIC by 6pm Monday 17 March 2008. MIS T811: Week 3

77

Readings •

Chapter 1: An Overview of Database Management in An in An Int In t r o d uc t io n t o Dat Datab abas ase e Systems (8th (8th editio edition), n), Addi son son-W -Wesley, esley, 200 2004 4 by C. J. Date. (QA (QA76.9.D3 76.9.D3 D D3659 3659 2004 2004))

• Cha Chapter pter 1: In Introd troduct uction ion to D Datab atabase ases s in DATABASE SYS SYSTE TEMS MS A Pract Practical ical A ppr oach to De Desig sign, n, Implementation, and Ma Manageme nagement nt (FOURT (FO URTH H EDITIO EDITION), N), Add ison is on Wesley, 200 2005 5 by Thomas Connolly and Carolyn Begg. (QA76.9.D26 C66 2005) 2005) MIS T811: Week 3

78

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close