20
Chapter 6—Relational Databases and SQL TRUE/FALSE 1. An entity in an accounting system can be classified as a resource, event, agent, or location. ANS: T 2. A field is an item of data that characterizes an entity or relationship. ANS: F 3. Attributes that consist of multiple subattributes are referred to as primary attributes. ANS: F 4. A key attribute is the attribute whose value is unique for every entity that will appear in the database. ANS: T 5. The customer street address is often used as the key attribute in an REA diagram. ANS: F 6. In an REA diagram, the rectangle is used to represent the composite attribute. ANS: F 7. The first step in REA is evaluating the attributes. ANS: F 8. Relationships define and map the way in which data can be extracted from a database in the future. ANS: T

ch06

  • Upload
    khae123

  • View
    227

  • Download
    0

Embed Size (px)

DESCRIPTION

ch06

Citation preview

Page 1: ch06

Chapter 6—Relational Databases and SQL

TRUE/FALSE

1. An entity in an accounting system can be classified as a resource, event, agent, or location.

ANS: T

2. A field is an item of data that characterizes an entity or relationship.

ANS: F

3. Attributes that consist of multiple subattributes are referred to as primary attributes.

ANS: F

4. A key attribute is the attribute whose value is unique for every entity that will appear in the database.

ANS: T

5. The customer street address is often used as the key attribute in an REA diagram.

ANS: F

6. In an REA diagram, the rectangle is used to represent the composite attribute.

ANS: F

7. The first step in REA is evaluating the attributes.

ANS: F

8. Relationships define and map the way in which data can be extracted from a database in the future.

ANS: T

9. A recursive relationship is a relationship between two different instances of an entity.

ANS: T

10. The DBMS approach yields data redundancies when a supervisor is supervised by a third employee.

ANS: F

11. A recursive relationship is created when there is an employee being supervised, and another employee is the supervisor.

ANS: T

12. Cardinality constraints relate to the specification of how many occurrences of an entity can participate in a given relationship with any one occurrence of the other entity in the relationship.

Page 2: ch06

ANS: T

13. The cardinality constraint is used to specify both the minimum and maximum participation of one entity in the relationship with the other entity.

ANS: F

14. The notation 1,N is used to specify the relationship type of one to many.

ANS: T

15. The notation of (1,1) is used to specify the relationship type of one to many.

ANS: F

16. REA stands for resources, entities and agents

ANS: F

17. The fundamental requirement for moving toward an event driven model is the complete integration of data related to an organization’s business events.

ANS: T

18. Enterprise systems are integrated software packages designed to provide complete integration of an organization's business information processing systems and all related data.

ANS: T

19. A collection of data representing multiple occurrences of an object, event, or agent is known as a relation.

ANS: T

20. A set of data that describes an instance of the entity represented by a relation is known as a tuple.

ANS: T

21. A missing value is called a non-null.

ANS: F

22. The secondary key is specified to identity each tuple in the relation.

ANS: F

23. SQL is a powerful database language that can be used to define database systems, query the database for information, generate reports from the database, and access databases from within programs using embedded commands.

ANS: T

Page 3: ch06

24. Referential integrity specifies that for every attribute in one relation that has been specified to allow reference to another relation, the tuple being referenced must be intact.

ANS: T

25. A relation in an ER model is the same as an entity in the REA model.

ANS: F

26. Most DBMS programs today that include SQL also include mechanisms within the DBMS itself for enforcing referential integrity.

ANS: T

27. The INSERT command is used to add a single tuple to an existing relation.

ANS: T

28. The UPDATE command demonstrates one of the weaknesses in most forms of SQL.

ANS: F

29. The DELETE command is used when we want to change one or more attribute values.

ANS: F

30. Queries of a database are driven by SELECT commands.

ANS: T

MULTIPLE CHOICE

1. An entity can be classified as all of the following excepta. resourceb. eventc. tupled. agent

ANS: C

2. A(n) ____ of an entity is anything in which we are interested that exists independently.a. agentb. composite attributec. attributed. instance

ANS: D

3. A(n) ____ is an item of data that characterizes an entity or relationshipa. agentb. composite attributec. attributed. instance

Page 4: ch06

ANS: C

4. Which of the following is the entity or agent?a. clientb. client numberc. client named. client street address

ANS: A

5. Which of the following is the key attribute?a. clientb. client numberc. client named. client street address

ANS: B

6. Which of the following is an attribute but least likely to be the key attribute?a. clientb. client numberc. client named. client street address

ANS: D

7. Which of the following is a subattribute?a. clientb. client numberc. client named. client street address

ANS: D

8. A data field in a traditional file is similar to a relational:a. tableb. attributec. tupled. row

ANS: B

9. For the following entity and attribute model, what would be the key attribute of the Students entity?

Page 5: ch06

a. social security numberb. namec. addressd. street

ANS: A

10. A key attribute is the attribute whose value is:a. undeterminableb. uniquec. larged. the same for all attributes

ANS: B

11. The mapping of the relationships between entities would be used in the development of a(n):a. context diagramb. logical DFDc. physical DFDd. REA Model

ANS: D

12. The sequence of steps in identifying relationships in a model is:a. evaluate entities as pairs, identify user existing and desired information, evaluate each

entity to determine if there is any need for two occurrences of the same entity type to be linked

b. identify user existing and desired information, evaluate entities as pairs, evaluate each entity to determine if there is any need for two occurrences of the same entity type to be linked

c. evaluate entities as pairs, evaluate each entity to determine if there is any need for two occurrences of the same entity type to be linked, identify user existing and desired information

d. evaluate each entity to determine if there is any need for two occurrences of the same entity type to be linked, evaluate entities as pairs, identify user existing and desired information

ANS: B

13. A recursive relationship is a relationship:a. between two similar entities of the same entity typesb. between two similar entities of different entity types

Page 6: ch06

c. between two different entities of the same entity typesd. between two different entities of different entity types

ANS: C

14. Which of the following is not a relationship type?a. one-to-manyb. one-to-onec. one-to-fewd. many-to-many

ANS: C

15. Which relationship type does (1, N) mean?a. one-to-manyb. one-to-onec. one-to-fewd. many-to-many

ANS: A

16. The cardinality constraint of a relationship relates to:a. specifying the minimum participation of one entity in the relationshipb. specifying the maximum participation of one entity in the relationshipc. the specification of how many occurrences of a relationship can participate in the given

relationship with any one occurrence of the other relationship in the entityd. the specification of how many occurrences of an entity can participate in the given

relationship with any one occurrence of the other entity in the relationship

ANS: D

17. Customers of Hanson Company, a home furnishings wholesaler, place orders by contacting a sales representative via a toll-free number. Identify the constraints of the following data model relationship.

a. 1:1b. 1:Nc. N:Md. N:1

ANS: B

18. The constraint that is used to specify both the minimum and maximum participation of one entity in the relationship with the other entity is called:a. cardinality constraintb. participation constraintc. economic constraintd. logical constraint

ANS: B

Page 7: ch06

19. Students at Macom University use an web-based course registration system. Identify the participation constraint of the following data model relationship. The university maintains student records until they graduate or do not enroll in a course for a 3-year period.

a. N:Mb. 1:Nc. (1,1):(0,N)d. (1,1):(1,N)

ANS: D

20. Enterprise systems are integrated software packages designed to provide complete integration of:a. an organization's accounting information systemb. an organization's business datac. an organization's business information processing systems and all related datad. an organization's management

ANS: C

21. A set of data that describes an instance of the entity represented by a relation is known as a(n) ____.a. tupleb. resourcec. agentd. event

ANS: A

22. Legacy systems do not usually have which of the following characteristics?a. developed on previous hardware (and/or software) platformsb. are easily adaptable to enterprise systemsc. have been used by an organization for a long period of timed. all of the above are typical characteristics of legacy systems

ANS: B

23. In a relational database, a relation is defined as a collection of data representing multiple occurrences of the following except:a. an objectb. an eventc. an activityd. an agent

ANS: C

24. ____ are defined as a set of data that describes an instance of the entity represented by a relation.a. Attributesb. Tuplesc. Primary keysd. Candidate keys

ANS: B

Page 8: ch06

25. ____ specifies that for every attribute value in one relation that has been specified in order to allow reference to another relation,the tuple being referenced must remain intact.a. Cardinality constraintb. Participation constraintc. Referential integrityd. Economic constraint

ANS: C

26. Which of following is not a step in the process for specifying relations based on REA diagrams?a. Determine the attributes for each of the entities.b. Determine the number of tables.c. Create a separate relational table for each entity.d. Implement the relationships among the entities.

ANS: B

27. A situation in which a particular supplier provides more than one type of inventory item to a firm and a particular type of inventory item is acquired from more than a single supplier is called a(n):a. one-to-one relationshipb. one-to-many relationshipc. many-to-many relationshipd. entity relationship

ANS: C

28. The following E-R diagram shows a M:N relationship between two relations. To map this E-R diagram into a logical database model:

a. divide the content of the Course relation to establish two relations having 1:N relationships

b. add the primary key of the Student relation as an attribute in the Course relationc. create a new relation whose primary key is a composite of the primary keys of two

relationsd. add the primary key of the Course relation as an attribute in the Student relation

ANS: C

29. Which of the following is not a proper SQL command for creating database relations?a. Create table employeeb. Create table training_completedc. Create clientd. Alter table release_time

ANS: C

30. To generate a standard report of a relational database, which of the following SQL commands would be used?a. Select reportb. Select viewc. Create report

Page 9: ch06

d. Create view

ANS: D

31. Which of the following relational commands would a manager use to combine the data from two related relations into a third relation?a. selectb. projectc. joind. display

ANS: C

32. In a relational database, the entity is represented as a(n):a. tableb. networkc. fieldd. attribute

ANS: A

33. Which is not a step in creating a relation using SQL?a. assign the relation a nameb. assign each attribute a namec. specify the constraints on the attributesd. specify the attributes of the constraints

ANS: D

34. Which is not an SQL command in which data can be changed in the database?a. Insertb. Deletec. Updated. Create

ANS: D

35. Which of the following is a valid SQL command?a. Modifyb. Insertc. Addd. Append

ANS: B

36. The SELECT statement has all but one of the following partsa. a list of attributes that we wish to SELECT from the databaseb. a WHEN clausec. a list of tables where these attributes can be foundd. a WHERE clause

ANS: B

The following table is a view of BILLING_HOURS from the various data elements in High-Tech Corp.'s relational database.

Page 10: ch06

BILLING_HOURS Employee_No Client_No Date Hours Billing_RateB122 F26768 20010823 8 150A632 F11555 20010823 7 100B122 F26768 20010824 8 150A632 F11555 20010824 6 100B122 F26768 20010825 9 150A632 F11555 20010825 10 100

37. Which of the following SQL statements would extract the employee number and date for every instance that an employee worked more than 8 hours any particular day?a. SELECT Employee_No, Date

FROM BILLING_HOURSWHERE Hours>8

b. QUERY Employee_No, DateFROM BILLING_HOURSWHERE Hours>8

c. SELECT Employee_No, DateWHERE Hours>8

d. QUERY BILLING_HOURSSELECT Employee_No, DateWHERE Hours>8

ANS: A

38. Which of the following SQL statements would extract the employee number and date for every instance that an had a billing rate of $150?a. SELECT Employee_No, Date

FROM BILLING_HOURSWHERE Rate=150

b. QUERY Employee_No, DateFROM BILLING_HOURSWHERE Rate=150

c. SELECT Employee_No, DateWHERE Rate=150

d. QUERY BILLING_HOURSSELECT Employee_No, DateWHERE Hours>8

ANS: A

39. Which of the following SQL statements would extract the client number and date for every instance that an had a billing rate of $150?a. QUERY BILLING_HOURS

SELECT Client_No, DateWHERE Rate=150

b. QUERY client_No, DateFROM BILLING_HOURSWHERE Rate=150

c. SELECT Client_No, DateWHERE Rate=150

d. SELECT Client_No, DateFROM BILLING_HOURSWHERE Rate=150

Page 11: ch06

ANS: D

40. Which of the following SQL statements would extract the client number and date for every instance that an employee worked less than 8 hours any particular day?a. QUERY BILLING_HOURS

SELECT Client_No, DateWHERE Hours<8

b. QUERY client_No, DateFROM BILLING_HOURSWHERE Hours>8

c. SELECT Client_No, DateWHERE Hours<8

d. SELECT Client_No, DateFROM BILLING_HOURSWHERE Hours<8

ANS: D

COMPLETION

1. A(n) ____________________ in an accounting system can be classified as a resource, event, agent, or location.

ANS: entity

2. A(n) ____________________ is an item of data that characterizes an entity or relationship.

ANS: attribute

3. Attributes that consist of multiple subattributes are referred to as _________________________.

ANS: composite attributes

4. A(n) _________________________ is the attribute whose value is unique for every entity that will appear in the database.

ANS: key attribute

5. ____________________ define and map the way in which data can be extracted from a database in the future.

ANS: Relationships

6. A(n) ______________________________ is a relationship between two different instances of an entity.

ANS: recursive relationship

7. The relationship that relates to the specification of how many occurrences of an entity can participate in the given relationship with any one occurrence of the other entity in the relationship is referred to as ______________________________.

ANS: cardinality constraint

Page 12: ch06

8. The ______________________________ is used to specify both the minimum and maximum participation of one entity in the relationship with the other entity.

ANS: participation constraint

9. The notation 1,N is used to specify the relationship type of _________________________.

ANS: one to many

10. REA stands for ____________________, ____________________, and ____________________.

ANS: resources, events, agents

11. __________________________________________________ are integrated software packages designed to provide complete integration of an organization's business information processing systems and all related data.

ANS:Enterprise resource planning systemsERP systems

12. A collection of data representing multiple occurrences of a resource, event, or agent is known as a(n) ____________________.

ANS: relation

13. A set of data that describes an instance of the entity represented by a relation is known as a(n) ____________________.

ANS: tuple

14. The _________________________ is specified to identity each tuple in the relation.

ANS: primary key

15. ___________________________________ specifies that for every attribute in one relation that has been specified to allow reference to another relation, the tuple being referenced must be intact.

ANS: Referential integrity

16. ____________________ is a powerful database language that can be used to define database systems, query the database for information, generate reports from the database, and access databases from within programs using embedded commands.

ANS: SQL

17. The ____________________ command is used to add a single tuple to an existing relation.

ANS:INSERTinsert

Page 13: ch06

18. The ____________________ command demonstrates one of the weaknesses in most forms of SQL.

ANS:DELETEdelete

19. The ____________________ command is used when we want to change one or more attribute values.

ANS:UPDATEupdate

20. Queries of a database are driven by ____________________ commands.

ANS:SELECTselect

PROBLEM

1. The following table is a view of BILLING_HOURS from the various data elements in ABC's relational database:

BILLING_HOURS Employee_No Client_No Date Hours Billing_RateB122 F11555 990823 8 150A632 F11555 990823 8 100B122 F11555 990824 8 150A632 F11555 990824 8 100B122 F11555 990825 8 150A632 F11555 990825 8 100B122 H12456 990826 8 150A632 H12456 990826 8 100A356 F11555 990826 8 57A432 H12456 990826 8 57A491 H12456 990826 8 57B122 F11555 990827 8 150A632 H12456 990827 8 100A356 F11555 990827 8 57B432 H12456 990827 8 57B491 H12456 990827 8 57

Required:

a. Using proper SQL commands, develop a query to extract billing data for Fleet Services (client number F11555), showing the employee number, date, hours, and billing rate.

b. Design a table showing the output that would be generated based upon your query created above.

ANS:a. SELECT Employee_No, Date, Hours, Billing_Rate

Page 14: ch06

FROM BILLING_HOURSWHERE Client_No='F11555'

b.

Employee_No Date Hours Billing_RateB122 990823 8 150.00A632 990823 8 100.00B122 990824 8 150.00A632 990824 8 100.00B122 990825 8 150.00A632 990825 8 100.00A356 990826 8  57.00B122 990827 8 150.00A356 990827 8  57.00

2. The following table is a view of TRAINING_COMPLETED from the various data elements in High-Tech Corp.'s relational database:

TRAINING_COMPLETED Employee_No Date Hours Train_Code11111 990823 8 1511152 990823 8 1511163 990823 8 4511111 990824 8 2511152 990824 8 2511163 990824 8 1511111 990825 8 4511152 990825 8 5511175 990825 8 4511111 990826 8 5511175 990826 8 5511111 990827 8 6511152 990827 8 4511163 990827 8 6511175 990827 8 65

Required:

a. Using proper SQL commands, develop a query to extract training data for employee Missy Pitman (employee number 11111), showing the date, hours, and training code.

b. Design a table showing the output that would be generated based upon your query created above.

ANS:a. SELECT Date, Hours, Train_Code

FROM TRAINING_COMPLETEDWHERE Employee_No='11111'

b.

Date Hours Train_Code

Page 15: ch06

990823 8 15990824 8 25990825 8 45990826 8 55990827 8 65

3. Based on the following abbreviated description of Avery University's course scheduling and student advising procedures, prepare an Entity-Relationship (E-R) diagram that reflects the key entities and relationships.

Course Scheduling:In consultation with the vice-president of Academic Affairs and the Registrar's Office, each academic department chair decides which courses will be offered each semester and how many sections of each course will be scheduled. Courses are scheduled in sections meeting at different times over the course of the week. Some courses are scheduled in multiple sections. The department chair also assigns a faculty member who teaches for his/her department to teach each course-section. Students enroll in courses-sections by submitting their schedule selections to the Registrar's Office. In assigning students to sections, the Registrar gives preference to students based on their class standing (i.e., Senior, Junior, Sophomore, and Freshman).

Student Advising:Student academic advising is done according to each student's major. Each student chooses a faculty advisor from his/her major department. While each student has only one "official" academic advisor, each faculty person advises several students, up to a maximum of 15 advisees.

ANS:See Figure TB-5.1.

Page 16: ch06