61
IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.1

IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Embed Size (px)

Citation preview

Page 1: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

IT203 Unit 2: Gather Information and Define Requirements

IT203 Unit 2: Gather Information and Define Requirements

Gathering Information

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.1

Page 2: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Ways to Gather Information

• Initial Interviews• Review Business Documents• Interviews with Stakeholders• Questionnaires• Work Shadowing

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.2

Page 3: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Initial Interviews

• The initial interviews should provide an overall picture of the purpose of the database.

• What you want at this point is to gather the goals and broad requirements of the database.

• Avoid too many specifics.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.3

Page 4: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Reviewing Business Documents

• Reviewing business documents can reveal many things relevant to development of the database:– Insight into daily business processes– How information is gathered and used– What information is gathered– The sequences used for gathering and passing

information

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.4

Page 5: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Database Domain

• The domain is the focus of the database.• If the database is to track inventory, then the

inventory content and processes within the company would form the domain of the database.

• For instance, if the database were for tracking clinical work in a dentist’s office, then the dental procedures and how they are captured would be the database domain.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.5

Page 6: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Requirements

• Requirements are things the database must do.

• For instance, an inventory database must:– Store all the relevant data about inventory

items.– Be able to both add and remove items from

the inventory.– Allow for the details about items to be

modified.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.6

Page 7: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Forms

• Forms are documents used to capture business information.

• They represent the “input” to a system.• They can be paper-based or on-line.• The fields filled in by users on the forms

are a good first guide to what fields the database will need to contain.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.7

Page 8: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Sample Form

Tutor Session Report Form

Tutor Name

Session Date

Session Time

StudentID

Student Name (NA if no student signed up)

Materials covered (NS if no show)

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.8

Page 9: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Reports

• Reports present “output” from the data.• Typically they summarize the data,

providing things like totals and averages.• These, too, are a good guide to the

content of the potential database since it will need to store any information needed to create the reports.

• Reports often contain graphs and charts.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.9

Page 10: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Sample Report

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.10

Page 11: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Other Documents• Manuals and procedures can be useful for

understanding work processes.• Memos and letters can provide insights into

how the data is used and who the major stakeholders are.

• Annual reports offer insights into the directions and plans of a company in which the database will play a part.

• Even Mission Statements and goals can be valuable, since the database should support the mission of the company.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.11

Page 12: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Things to Watch for When Reviewing Documents

• Make sure you understand all the abbreviations and terms.

• Make sure you understand the purpose of the document within the context of the data with which you are working.

• Make sure you understand where in the process the document belongs.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.12

Page 13: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Types of Database

• A database can serve several different functions.

• Three of them are:– Transaction database– Management Information System– Business Intelligence

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.13

Page 14: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Transaction Databases

• These are databases that are optimized to collect and process business transactions such as sales.

• They need to be fast and efficient.• They often need to be available 24 hours a

day, 7 days a week.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.14

Page 15: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Information Management Systems

• Information management systems are optimized to process the transaction information, creating summaries and reports that are useful to business managers.

• They often work with a copy of the transaction data so as not to slow down the transaction database.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.15

Page 16: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Business Intelligence

• Business intelligence moves beyond management systems.

• It provides tools for “mining” data to look for patterns and trends that might help the business improve its offerings or service.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.16

Page 17: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Identifying stakeholders

• You should first identify all the relevant stakeholders.

• A stakeholder is anyone who has a “stake” in the database project.

• This includes not only management, but also anyone who will have to work with the database.

• It may also include customers.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.17

Page 18: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Interviews

• Interviews are especially good for asking “open-ended” questions.

• An open-ended question is one that doesn’t have a set answer, such as “What is the aspect of the current database that gives you the most trouble?”

• It is important to interview all the stakeholders to get their perspectives, not just the management.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.18

Page 19: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Preparing for an Interview

• It is important to always prepare for an interview.

• Prepare questions ahead of time.• Be aware of how much total time you

have for the interview.• Allot a certain amount of time to each

question.• Allow some time to follow up questions.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.19

Page 20: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Example Interview Preparation FormTutor Interview

Total time: 45 minutes. Allow 5 minutes for introductions.

Question For Time AllottedHow do you set your schedule? Tutors 5 minutesHow do you sign up for a tutoring session? What would make the process easier?

Students 3 minutes

What do you typically put in the section of the tutor report labeled “Materials Covered?”

Tutors 2 minutes

How do you check to see if a student is in the class they are being tutored for?

Tutors 3 minutes

Why do you sometimes not get the studentID number

Tutors 2 minutes

How do you cancel a session? Tutors ,Students 5 minutesWould you be willing to enter your demographic information to get tutoring?

Students 2 minute

What is the number one thing you would like to see changed in the current system?

Tutors, Students 8 minutes

What part of the current system do you like?

Tutors, Students 5 minutes

Time for follow up questions Tutors, students 5 minutes

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.20

Page 21: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Conducting the Interview

• Lay out the rules and the time constraints from the beginning.

• Facilitate the interview, making sure everyone has a chance to respond.

• Politely cut off overly long responses or those that stray from the subject at hand.

• If possible, record the interview or have someone you trust take notes. It is almost impossible to facilitate an interview and take good notes.Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.21

Page 22: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Follow Up for Interviews

• Transcribe the notes while they are still fresh in your mind, ideally within 24 hours.

• Think of any follow-up questions to ask in person or in questionnaires.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.22

Page 23: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Questionnaires

• Questionnaires are useful for asking “closed questions.”

• Closed questions are questions that have a specific answer, such as yes/no or multiple choice.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.23

Page 24: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Preparing Questionnaires

• Make sure your questions are not ambiguous.

• Make sure you get a representative sample back.

• Too small of a return or a return that is not balanced among the appropriate stakeholders may not give you valid information.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.24

Page 25: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Sample Questionnaire1. Would you be willing to enter demographic information

such as gender and ethnicity to sign up for tutoring?YesNo

2. Would you be willing to list the classes in which you are currently enrolled?

YesNo

3. Which is the most important factor when you are looking for a tutoring session to sign up for?

The particular tutorThe time slotNeither of the above

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.25

Page 26: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Comparing Questionnaires and Interviews

Interviews• Good for open-ended

questions• More time-intensive

and more costly• Better for complex

issues and views

Questionnaires• Good for closed -ended

questions• Less time-intensive and

less expensive• Capture a wider variety

of views• Harder to judge the

accuracy

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.26

Page 27: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Work Shadowing

• Work shadowing consists of observing stakeholders as they work with the current database.

• This allows the developer to:– See how the data is actually processed in a day

by day routine.– See “exceptions” to the rule that may not be

documented.• It also may uncover other undocumented

processes that are important to the function of the database.Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.27

Page 28: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Documentation

• It is important to keep samples of all the business documents you have reviewed.

• Keep all notes about the abbreviations and field contents.

• Keep summaries and transcripts of interviews.

• Keep summaries of questionnaire results.• Keep summaries of work shadowing

reports.Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter2.28

Page 29: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic,

mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Page 30: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

IT203 Unit 2: Gather Information and Define Requirements

IT203 Unit 2: Gather Information and Define Requirements

Requirements and Business Rules

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.30

Page 31: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Client-Server Relations

• Much of software can be divided into one of two types:– Server– Client

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.31

Page 32: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Servers

• A server is software that offers “services” to other software.

• For instance, a Web server provides Web pages that are requested by a browser.

• Databases usually behave as servers.• Some machines are optimized to host

server software. They are also commonly referred to as servers.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.32

Page 33: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Clients

• Clients are software that request services.• A browser, for instance, requests a Web

page to load and view.• An application client can request data

from a database.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.33

Page 34: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Client Server Example

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.34

Page 35: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Review of the Issues

• Reviewing the issues with the current data management system is a good place to start.

• Several of the requirements of the new database will be to resolve those issues.

• Reviewing the issues also helps you refocus on the “problem domain.”

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.35

Page 36: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Problem Domain

• The problem domain represents the business problems a database is meant to solve.

• For a retail sales database, for instance, the problem domain is the sale, and all that is involved with the sale.

• For a science database dealing with earthquakes, the domain would be the locations, sizes, and depths of earthquakes. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapte3.36

Page 37: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Requirements

• It is important to identify all the requirements of the database.

• A requirement represents something the database must store or do.

• There are several types of requirements:– Data requirements– Report requirements– Security requirements

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.37

Page 38: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Data Requirements

• Data requirements refer to the attributes the database must store in order to meet the information needs of an organization.

• It is important to identify these data requirements as completely as possible.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.38

Page 39: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Report Requirements

• Report requirements refer to the reports the database will have to generate.

• For example, the Tutor database will have to report on tutor’s hours, the numbers of unduplicated student sessions and the demographics of students using the tutoring services, among others.

• The data required to generate those reports must be in the database. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.39

Page 40: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Security Requirements

• Security requirements refer to the limits that must be placed on database access in order to protect the integrity and privacy of the data in the database.

• Typically, different users of the database will have different levels of access depending on their needs.

• Users should have access to the data and resources they need to do their work, but no more. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.40

Page 41: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Actors and Requirements

• It is useful to think about requirements in terms of each of the actors who will be using the database.

• What does that particular actor need to do with the data in order to do his/her job?

• What are the limits on what each actor should be able to do?

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.41

Page 42: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Access Requirements

• Access is usually defined in terms of what kinds of things a user can do in the database.

• For instance, a user can be given permission to SELECT some data – that is, to view it – but not other data.

• A user may be given permission to edit certain data, but not all data.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.42

Page 43: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Types of Security Requirements

Type of Access Description

Create The permission to make new database objects such as tables or views

Alter The permission to modify database objects

Drop The permission to remove database object

Select The permission to see data in a table or view

Update The permission to modify data in a table

Insert The permission to add data rows to a table

Delete The permission to remove data rows from a table

Execute The permission to run database executables such as stored procedures

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.43

Page 44: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Business Rules

• A business rule is a rule about how data is collected, stored, or processed.

• Examples of business rules:– All quarter grades must be between 0 and 4.– No patron can have more than 20 items

checked out at a time.– Payments must be made within 30 days or a

$25 late fee will be added.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.44

Page 45: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Enforcing Business Rules

• Some business rules can be enforced in the database itself by placing constraints on the data. – The quarter grade must be between 0 and 4.

• Other business rules must be enforced through other means such as “triggers.”

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.45

Page 46: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Triggers

• A trigger is a block of SQL code that is triggered by an event such as an INSERT, UPDATE, or DELETE.

• Triggers can be used to enforce rules such as “No patron can check out more that 20 items.”

• When the database inserts a new item, the trigger fires and totals the number of unreturned items. If it is greater than 20 it can notify the librarian or the patron.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.46

Page 47: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Reviewing Requirements and Business Rules

• When you have listed all the requirements and business rules you can discover, you should always review them with the chief stakeholders.

• Use the review to make sure you have a complete list of requirements.

• Also make sure you have understood the business rules and processes.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.47

Page 48: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

A Little Bit of Grammar

• This is a technique to help identify the data requirements for a database.

• Review all the documents, interviews and questionnaires and list all the major nouns.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.48

Page 49: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Grouping Around Themes

• The next step is to sort the nouns into broad themes or groups.

• These themes may become entities in your database design.

• The other nouns that belong to the those themes will become attributes.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.49

Page 50: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Entities

• Entities are things that the database is concerned with.

• In the tutoring database, for instance major themes are student, class, tutor, session, and request.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.50

Page 51: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Attributes

• Attributes represent data that describe entities.

• Attributes of student, for instance, include:– Student ID– Student name– Student address– Student phone, etc.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.51

Page 52: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Keys

• When you have your preliminary entities and attributes defined, you can start thinking about keys.

• There are several types of keys:– Primary keys– Candidate keys– Natural keys– Composite keys– Surrogate keys

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.52

Page 53: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Primary Keys

• A primary key uniquely identifies a row of data.

• A primary key must be unique for every row (that is it can never repeat in the table that will result from the entity).

• For instance, a student ID can uniquely identify an individual student and the data associated with him or her.

• Every entity should have a primary key.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.53

Page 54: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Candidate Keys

• A candidate key is an attribute or attributes of an entity that have the potential to become a primary key.

• Candidate keys are not actual keys, but are a list of attributes that should be considered when choosing the primary key.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.54

Page 55: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Natural Keys

• There are basically two ways of making keys: natural and surrogate.

• Natural keys are keys formed by using an attribute that “naturally” belongs to the entity, such as a student ID or a phone number.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.55

Page 56: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Composite Keys

• Composite keys are keys composed of more than one attribute.

• For example, to get a unique designation of a course section, it is necessary to combine the quarter, the year, and the item number.

• Composite keys are one key made out of many parts.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapte3.56

Page 57: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Surrogate Keys

• Surrogate keys are keys that have no business meaning.

• Often they are just integers incremented row by row.

• They can also be things such as time stamps of auto-generated GUIDs.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.57

Page 58: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Comparison Between Natural and Surrogate Keys: Advantages

Natural Keys• Protect better against

accidently repeating the same information.

• Belong to the entity and tend to make foreign keys more understandable.

Surrogate Keys• Are always unique.• Do not contain any business

logic and are therefore not subject to changes in business rules.

• Are easier to define and use.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.58

Page 59: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Comparison Between Natural and Surrogate Keys: Disadvantages

Natural Keys• Uniqueness is hard to

guarantee.• May require clumsy

composite keys consisting of several attributes to be unique.

• Are subject to changes in business rules (think of Social Security numbers, for instance).

Surrogate Keys• Automatically grant

uniqueness to a row, making it easier to accidentally insert the same information twice.

• Have no relation to the data, making database relations less readable.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.59

Page 60: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

Documentation

• All requirements and business rules should be documented clearly and stored.

• Even preliminary definitions of entities, attributes, and keys should be kept for later reference.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter3.60

Page 61: IT203 Unit 2: Gather Information and Define Requirements Gathering Information Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter2.1

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic,

mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall