DD Database Design Learner

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 98

DD Database Design Learner – English

Section 1 – Introduction
1. Every time you shop online, it is likely you will be accessing a database. True or False?
A. Benar
B. Palsu

2. Databases are used in most countries and by most governments. Life, as we know it, would
change drastically if we no longer had access to databases. True or False?
A. benar
B. Palsu

3. Oracle was one of the first relational database systems available commercially. True or False?
A. benar
B. Palsu

4. Data Modeling is the last step in the database development process. True or False?
A. benar
B. Palsu

5. Once you have learned how to write programs and build systems, you no longer need any input or
involvement from any users as you are perfectly capable of delivering the systems that businesses
need and want.
A. True. Users delay the delivery of a system by changing their minds and adding new
requirements.
B. True. Users never know what they want anyway, so building systems is best left to the
professionals.
C. False. Business requirements can and will change. For instance new legal requirements
may arise.
D. True. The only requirement for creating a perfect system is a perfect programmer.

6. The market for IT professionals is still increasing and will continue to do so in the future as the
world gets ever more dependent on computer systems. True or False?
A. True
B. False

7. The main subject areas taught by the Oracle Academy are:


A. Data Modeling, SQL, and PL/SQL
B. Database performance tuning
C. Systems programming and computer architecture
D. Computer Repairs

8. Users could directly interact with which of the following software to access essential business
applications? (Choose three)

(Choose all correct answers)


A. Operating System software
B. GUI software
C. Server software
D. Internet Browser software

9. The overall mission of the Oracle Corporation is to use the internet and fast processing servers to
build its own network. True or False?
A. True
B. False

10. A specialized type of software, which controls and manages the hardware in a computer system.
A. Software
B. Client
C. Operating System
D. Hardware

11. Software cannot operate without Hardware. True or False?


A. True
B. False

12. Personal computers (PCs) have been in existence since 1950. True or False?
A. True
B. False

13. Which of the following are examples of data becoming information:


A. Student age -> average age of all students in class
B. Bank deposit amount -> total account balance
C. Winning time for a race -> length of race
D. Price of a computer -> total sales of all computers for a company
E. A, B, and D

14. Consider your school library. It will have a database with transaction details of the books that are
borrowed by students. Is a detail of one student borrowing one book considered Data or
Information?
A. Data
B. Information
C. Both
D. Neither

15. What is the difference between "information" and "data"?


A. Data turns into useful information. It is stored in a database and accessed by systems
and users.
B. Information and data have no differences - they are two words for the same thing.
C. Data is held and understood only by users.
D. Information is held and understood only by users

Section 2 - Entities and Attributes


1. The Physical Model is derived from the Conceptual Model. True or False?
A. True
B. False

2. Data modeling is performed for the following reasons: (Choose Two)


(Choose all correct answers)
A. It helps discussions and reviews.
B. We do not need datamodels; we can just start coding right away.
C. We draw an ERD solely to please the users; once completed, the ERD is never referred to
again as it serves no purpose in the real world.
D. The ERD becomes a blueprint for designing the actual system.

3. Data modeling is performed for the following reasons: (Choose Two)


(Choose all correct answers)
A. It helps discussions and reviews.
B. We draw an ERD solely to please the users; once completed, the ERD is never referred to
again as it serves no purpose in the real world.
C. The ERD becomes a blueprint for designing the actual system.
D. We do not need datamodels; we can just start coding right away.

4. An ERD is an example of a Logical Model. True or False?


A. True
B. False

5. Which of the following statements about Entities are true? (Choose 3)


(Choose all correct answers)
A. "Something" of significance to the business about which data must be known.
B. A name for a set of similar "things"
C. They are usually a noun.
D. They never have Instances

6. Which of the following entities most likely contains valid attributes? (Choose two)
(Choose all correct answers)
A. Entity: Home. Attributes: Number of Bedrooms, Owner, Address, Date Built
B. Entity: Pet. Attributes: Name, Birthdate, Owner
C. Entity: Mother. Attributes: Name, Birthdate, Occupation, Start Date
D. Entity: Car. Attributes: Owner Occupation, Owner Salary, Speed

7. Unique Identifiers:
A. Distinguish nothing
B. Distinguish one instance of an entity from all other instances of that entity
C. Distinguish one entity from another
D. Distinguish all entities in a database
8. A/an _________ is defined as "Something" of significance to the business about which data must
be known.
A. Instance
B. Relationship
C. Entity
D. None of the above

9. All of the following would be instances of the entity PERSON except which?
A. Grace Abinajam
B. Male
C. Angelina Rosalie
D. David Jones
10. Which of the following statements about attributes are true? (Choose 3)
(Choose all correct answers)
A. They have a data type, such as number or character string.
B. They describe, qualify, quantify, classify, or specify an entity.
C. They must be single valued.
D. They are often adjectives.

11. Which of the following attributes is suitable to be a Unique Identifier?


A. Address
B. Social Security Number
C. Last name
D. First name

12. Which of the following are examples of ENTITY: Instance ? (Choose Two)
A. MEAT PRODUCT: Lettuce
B. TRANSPORTATION METHOD: Car
C. ANIMAL: Dog
D. BODY PART: Larry Ellison

13. Entity Relationship modeling is dependent on the hardware or software used for implementation,
so you will need to change your ERD if you decide to change Hardware Vendor. True or False?
A. True
B. False

14. A well structured ERD will show only some parts of the finished data model. You should never
try to model the entire system in one diagram, no matter how small the diagram might be. True or
False?
A. True
B. False

15. An Entity Relationship model is independent of the hardware or software used for
implementation. True or False?
A. True
B. False

Section 3 – Relationship Basic


1. When reading a relationship between 2 entities, the relationship is read both from left to right and
right to left. True or False?
A. True
B. False

2. Which of the following are used to show a relationship on an ERD? (Choose Three)
(Choose all correct answers)
A. # symbol.
B. Crow's foot.
C. Solid line.
D. Dashed line.

3. ERDish describes a relationship in words. True or False?


A. True
B. False
4. When reading the relationships in an ERD, you are said to be speaking:
A. ERDish
B. Relationship-ish
C. Entity-ish
D. Gibberish

5. The many end of a Relationship is called:


A. Pigs Ear
B. Crows Ear
C. Crows Foot
D. Gulls Foot

6. Entity names are always singular. True or False?


A. True
B. False

7. Matrix Diagrams are used to verify that all relationships have been identified for an ERD. True or
False?
A. True
B. False

8. Matrix Diagrams show Optionality and Cardinality of the ERDs they document. True or False?
A. True
B. False

9. Matrix Diagrams are developed BEFORE the ERD. True or False?


A. True
B. False

10. Which of the following are used to show Cardinality on an ERD? (Choose two)
(Choose all correct answers)
A. Single toe.
B. Crow's foot.
C. Dashed line.
D. Solid line.

11. What are the three properties that every relationship should have?
A. Name, optionality, arcs
B. A UID bar, a diamond, an arc
C. Transferability, degree, name
D. Name, optionality, cardinality

12. One Relationship can be mandatory in one direction and optional in the other direction. True or
False?
A. True
B. False

13. Relationship Cardinality is important. True or False?


A. True
B. False
14. Which of the following are true about Relationship Optionality? (Choose two)
(Choose all correct answers)
A. Optionality specifies a counting number (like 1, 2, 3, 4 etc.) in a relationship.
B. Optionality answers "may or must".
C. Optionality specifies only singularity or plurality, but not a specific plural number.
D. Optionality specifies whether something is required or not.

15. Relationships can be either mandatory or optional. True or False?


A. True
B. False

Section 4 – Super/Sub Types and Business Rules


1. Business rules are important to data modelers because:
A. They capture all of the needs, processes, and required functionality of the business.
B. All Business rules are easily implemented in the ERD diagram.
C. The data modeler must focus on structural rules, because they are easily represented
diagrammatically and eliminate other rules that involve extra procedures or programming.
D. Both A and C are true.

2. How would you model a business rule that states that on a student's birthday, he does not have to
attend his classes?
A. Make the attribute Birthdate mandatory
B. Use a supertype
C. You cannot model this. You need to document it
D. Use a subtype
3. How would you model a business rule that states that girls and boys may not attend classes
together?
A. Supertype STUDENT has two subtypes BOY and GIRL which are related to GENDER,
which is related to CLASS
B. Make the attribute Gender optional
C. Make the attribute Gender mandatory
D. Use a supertype

4. Can all constraints be modeled on an ER diagram?


A. No, but you just explain them to the users so they can enforce them
B. No, and those that cannot be modeled should be listed on a separate document to be
handled programmatically
C. No, in which case you should let the database administrator handle them
D. Yes, all constraints must be modeled and shown on the ER diagram

5. A new system would have a mixture of both Procedural and Structural Business Rules as part of
the documentation of that new system. True or False?
A. True
B. False

6. A business rule such as "We only ship goods after customers have completely paid any
outstanding balances on their account" is best enforced by:
A. Creating additional programming code to verify no goods are shipped until the account
has been settled in full.
B. Making the payment attribute null.
C. Making the payment attribute optional.
D. We need to trust our customers, and we know they will pay some day.

7. Why is it important to identify and document structural rules?


A. Ensures we know what data to store and how that data works together.
B. Ensures nothing. There are no benefits to be gained from documenting your Structural
Business Rules. We need to concentrate on the Procedural Business Rules only.
C. Ensures we know what processes are in place and how to program them.
D. All of the Above.

8. All instances of a subtype may be an instance of the supertype but does not have to. True or
False?
A. True
B. False

9. All instances of the supertype must be an instance of one of the subtypes. True or False?
A. True
B. False

10. A subtype can have a relationship not shared by the supertype. True or False?
A. True
B. False

11. A supertype can only have two subtypes and no more. True or False?
A. True
B. False
12. A subtype is shown on an ERD as an entity with a one to many relationship to the supertype. True
or False?
A. True
B. False

13. A subtype is drawn on an ERD as an entity inside the "softbox" of the supertype. True or False?
A. True
B. False

14. You can only create relationships to a Supertype, not to a Subtype. True or False?
A. True
B. False

15. All instances of a subtype must be an instance of the supertype. True or False?
A. True
B. False

Section 5 – Relationship Fundamentals


1. Relationships can be Redundant. True or False?
A. True
B. False

2. Which of the following pairs of entities is most likely to be modeled as a M:M relationship?
A. CAR and WHEEL
B. TREE and BRANCH
C. PERSON and FINGERPRINT
D. TEACHER and SUBJECT AREA

3. What uncommon relationship is described by the statements: "Each DNA SAMPLE may be taken
from one and only one PERSON and each PERSON may provide one and only one DNA
SAMPLE"
A. One to Many Mandatory
B. One to One Optional
C. Many to Many Mandatory
D. One to Many Optional

4. Many to many relationships must be left in the Model. It is important to have them documented as
M-M. True or False?
A. True
B. False

5. If the same relationship is represented twice in an Entity Relationship Model, it is said to be:
A. Resourceful
B. Redundant
C. Replicated
D. Removable

6. Non-transferable relationships can only be mandatory, not optional. True or False?


A. True
B. False

7. A non-transferable relationship means the relationship is manatory at both sides. True or False?
A. True
B. False

8. A non-transferable relationship is represented by which of the following symbols?


A. Circle
B. Heart
C. Diamond
D. Triangle

9. Which of the following is an example of a non-transferable relationship


A. TEACHER to SCHOOL
B. EMPLOYEE to DEPARTMENT
C. STUDENT to COURSE
D. PERSON to BIRTH PLACE

10. Every ERD must have at least one non-transferable relationship. True or False?
A. True
B. False

11. Intersection Entities often have the relationships participating in the UID, so the relationships are
often barred. True or False?
A. True
B. False
12. If an intersection entity is formed that contains no attributes of its own, its uniqueness may be
modeled by
A. Creating new attributes.
B. Barring the relationships to the original entities.
C. Placing the UID attributes from the original entities into the intersection entity.
D. None of the above.

13. When you resolve a M:M, you simply re-draw the relationships between the two original entities;
no new entities are created. True or False?
A. True
B. False

14. A barred relationship on an ERD signifies that the UID of the intersection entity is inherited from
the entities that made up the original many to many relationship. True or False?
A. True
B. False

15. What do you call the entity created when you resolve a M:M relationship?
A. Intersection entity
B. Inclusion entity
C. M:M entity
D. Recursive entity

Database Design Midterm Exam


Section 1
1. Businesses involved in any of the following typically use databases to handle their data: Finance,
Logistics, Commerce, Procurement, and Distribution? True or False?
A. True
B. False

2. Software cannot operate without Hardware. True or False?


A. True
B. False

3. Personal computers (PCs) have been in existence since 1950. True or False?
A. True
B. False

4. In the grid computing model, resources are pooled together for efficiency. True or False?
A. True
B. False

5. The demand for Information Technology professionals in today's market is increasing. True or
False?
A. True
B. False
6. Consider your school library. It will have a database with transaction details of the books that are
borrowed by students. Is the total number of books out on loan in one given month considered
Data or Information?
A. Data
B. Information
C. Both
D. Neither

7. What is the difference between "information" and "data"?


A. Information is held and understood only by users.
B. Data turns into useful information. It is stored in a database and accessed by systems and
users.
C. Data is held and understood only by users.
D. Information and data have no differences - they are two words for the same thing.

8. Every time you shop online, it is likely you will be accessing a database. True or False?
A. True
B. False

9. Entities are transformed into Tables during the Database Design process. True or False?
A. True
B. False

10. Data Modeling is the last step in the database development process. True or False?
A. True
B. False

Section 2
11. An ERD is an example of a Physical Model. True or False?
A. True
B. False

12. Documenting Business Requirements helps developers control the scope of the system and
prevents users from claiming that the new system does not meet their business requirements. True
or False?
A. True
B. False

13. Data models are drawn to show users the actual Data that their new system will contain; only
Data listed on the Diagram can be entered into the Database. True or False?
A. True
B. False

14. Many reasons exist for creating a conceptual model. Choose three appropriate reasons from the
options below. (Choose all correct answers)
A. They model the information flow of data.
B. They accurately describe what a physical model will contain.
C. They capture current and future needs.
D. They capture the implementation details of the physical model.
E. They model functional and informational needs.
15. Entity Relationship modeling is dependent on the hardware or software used for implementation,
so you will need to change your ERD if you decide to change Hardware Vendor. True or False?
A. True
B. False

16. Which of the following statements are true about ERD's? (Choose Two). (Choose all correct
answers)
A. A piece of information can be shown multiple times on an ERD.
B. A piece of information should only be found in one place on an ERD.
C. All data must be represented on the ERD, including derived summaries and the result of
calculations.
D. You should not model derivable data.

17. The purpose of an ERD is to document the proposed system and facilitate discussion and
understanding of the requirements captured by the developer. True or False?
A. True
B. False

18. What is the purpose of a Unique Identifier?


A. Create an entity that is unlike any other entity aside from itself.
B. To identify a specific row within a table, using one or more columns and/or foreign keys.
C. To uniquely determine a table and columns within that table.
D. To identify one unique instance of an entity by using one or more attributes and/or
relationships.

19. Which of the following are examples of ENTITY: Instance ? (Choose Two). (Choose all correct
answers)
A. ANIMAL: Dog
B. BODY PART: Larry Ellison
C. TRANSPORTATION METHOD: Car
D. MEAT PRODUCT: Lettuce

20. Unique Identifiers:


A. Distinguish one entity from another
B. Distinguish one instance of an entity from all other instances of that entity
C. Distinguish nothing
D. Distinguish all entities in a database

21. Which of the following attributes is suitable to be a Unique Identifier?


A. Social Security Number
B. Address
C. First name
D. Last name

22. In the following statements, find two good examples of ENTITY: Instance. (Choose Two).
(Choose all correct answers)
A. DAIRY PRODUCT: milk
B. VEGETABLE: grows
C. TRAIN: runs
D. BOOK: Biography of Mahatma Gandhi
23. Which of the following statements about attributes are true? (Choose 3). (Choose all correct
answers)
A. They describe, qualify, quantify, classify, or specify an entity.
B. They have a data type, such as number or character string.
C. They are often adjectives.
D. They must be single valued.

Section 3
24. Relationship Cardinality is important. True or False?
A. True
B. False

25. Relationships always exist between


A. 2 attributes
B. 3 or more entities
C. 2 entities (or one entity and itself)
D. 3 or more attributes

26. One Relationship can be mandatory in one direction and optional in the other direction. True or
False?
A. True
B. False

27. Matrix Diagrams show Optionality and Cardinality of the ERDs they document. True or False?
A. True
B. False

28. Matrix Diagrams are used to verify that all relationships have been identified for an ERD. True or
False?
A. True
B. False

29. Entity boxes are drawn as


A. Soft Boxes
B. Bold Circles
C. Hard Boxes
D. Normal Circles

30. When reading a relationship between 2 entities, the relationship is read both from left to right and
right to left. True or False?
A. True
B. False

31. Relationship names are not shown on an ERD. True or False?


A. True
B. False

Section 4
32. How should you handle constraints that cannot be modeled on an ER diagram?
A. Always let the network architect handle them
B. Explain them to the users so they can enforce them
C. List them on a separate document to be handled programmatically
D. All constraints must be modeled and shown on the ER diagram

33. How would you model a business rule that states that girls and boys may not attend classes
together?
A. Make the attribute Gender optional
B. Make the attribute Gender mandatory
C. Supertype STUDENT has two subtypes BOY and GIRL which are related to GENDER,
which is related to CLASS
D. Use a supertype

34. Which of the following is an example of a structural business rule?


A. All products will have a selling price no less than 30 % greater than wholesale.
B. Buildings to be purchased by the business must be current with earthquake building code.
C. All employees must belong to at least one department.
D. All overdue payments will have an added 10 % late fee.

35. Can all constraints be modeled on an ER diagram?


A. No, in which case you should let the database administrator handle them
B. Yes, all constraints must be modeled and shown on the ER diagram
C. No, but you just explain them to the users so they can enforce them
D. No, and those that cannot be modeled should be listed on a separate document to be handled
programmatically
36. All ER diagrams must have one of each of the following: (Choose two). (Choose all correct
answers)
A. One or more Entities
B. Relationships between entities
C. Arcs
D. At least one supertype and subtype

37. A supertype can only have two subtypes and no more. True or False?
A. True
B. False

38. All instances of the supertype must be an instance of one of the subtypes. True or False?
A. True
B. False

39. You can only create relationships to a Supertype, not to a Subtype. True or False?
A. True
B. False

40. All instances of a subtype must be an instance of the supertype. True or False?
A. True
B. False

Section 5
41. A Diamond on a relationship indicates the Relationship as Non-Tranferable. True or False?
A. True
B. False

42. If a relationship can be moved between instances of the entities it connects, it is said to be:
A. Recursive
B. Implicit
C. Transferable
D. Committed

43. Every ERD must have at least one non-transferable relationship. True or False?
A. True
B. False

44. Which of the following pairs of entities is most likely to be modeled as a M:M relationship?
A. TREE and BRANCH
B. CAR and WHEEL
C. TEACHER and SUBJECT AREA
D. PERSON and FINGERPRINT

45. If the same relationship is represented twice in an Entity Relationship Model, it is said to be:
A. Removable
B. Redundant
C. Resourceful
D. Replicated

46. Which of the following pairs of entities is most likely to be modeled as a 1:1 relationship?
A. PERSON and FINGERPRINT
B. TREE and BRANCH
C. CAR and WHEEL
D. TEACHER and SUBJECT AREA

47. If two entities have two relationships between them, these relationships can be either
_____________ or _____________ .
A. Redundant and Replicated
B. Redundant or Required
C. Replicated or Required
D. Resourced and Really Good

48. When you resolve a M:M by creating an intersection entity, this new entity will always inherit:
A. The UID's from the entities in the original M:M.
B. The attributes of both related entities.
C. Nothing is inherited from the original entities and relationship.
D. A relationship to each entity from the original M:M.

49. When you resolve a M:M, you simply re-draw the relationships between the two original entities;
no new entities are created. True or False?
A. True
B. False
50. Intersection Entities often have the relationships participating in the UID, so the relationships are
often barred. True or False?
A. True
B. False

Section 6 – UIDs and Normalization


1. People are not born with 'numbers', but a lot of systems assign student numbers, customer IDs,
etc. ᅠThese are known as a/an ______________ UID.
A. Artificial
B. Identification
C. Unrealistic
D. Structured

2. Where an entity has more than one attribute suitable to be the Primary UID, these are known as
_____________ UIDs.
A. Candidate
B. Composite
C. Secondary
D. Simple

3. There is no limit to how many attributes can make up an entity's UID. True or False?
A. True
B. False

4. If an entity has no attribute suitable to be a Primary UID, we can create an artificial one. True or
False?
A. True
B. False

5. If an entity has a multi-valued attribute, to conform to the rule of 1st Normal Form we:
A. Create an additional entity and relate it to the original entity with a 1:M relationship.
B. Make the attribute optional
C. Do nothing, an entity does not have to be in 1st Normal Form
D. Create an additional entity and relate it to the original entity with a M:M relationship.

6. An entity ORDER has the attributes Order ID, Order Date, Product id, Customer ID. This entity is
in 1st Normal Form. True or False?
A. True
B. False

7. To convert an entity with a multi valued attribute to 1st Normal Form, we create an additional
entity and relate it to the original entity with a 1:1 relationship. True or False?
A. True
B. False

8. When data is stored in more than one place in a database, the database violates the rules of
___________.
A. Decency
B. Normalcy
C. Replication
D. Normalization

9. What is the rule of Second Normal Form?


A. No non-UID attributes can be dependent on any part of the UID.
B. Some non-UID attributes can be dependent on the entire UID.
C. All non-UID attributes must be dependent upon the entire UID.
D. None of the above

10. Examine the following entity and decide how to make it conform to the rule of 2nd Normal Form:
ENTITY: RECEIPT
ATTRIBUTES:
#CUSTOMER ID
#STORE ID
STORE LOCATION
DATE
A. Move the attribute STORE LOCATION to a new entity, STORE, with a UID of STORE
ID, and create a relationship to the original entity.
B. Do nothing, it is already in 2nd Normal Form.
C. Move the attribute STORE LOCATION to a new entity, STORE, with a UID of STORE
LOCATION, and create a relationship to the original entity.
D. Delete the attribute STORE ID

11. Any Non-UID attribute must be dependent upon the entire UID. True or False?
A. True
B. False

12. Examine the following Entity and decide which rule of Normal Form is being violated:
ENTITY: CLIENT
ATTRIBUTES:
# CLIENT ID
FIRST NAME
LAST NAME
STREET
CITY
A. 1st Normal Form.
B. 2nd Normal Form.
C. 3rd Normal Form.
D. None of the above, the entity is fully normalised.

13. A transitive dependency exists when any attribute in an entity is dependent on any other non-UID
attribute in that entity. True or False?
A. True
B. False

14. When any attribute in an entity is dependent on any other non-UID attribute in that entity, this is
known as:
A. Transitive dependency
B. Functional dependency
C. Dependency
D. Non-dependency

15. The Rule of 3rd Normal Form states that No Non-UID attribute can be dependent on another non-
UID attribute. True or False?
A. True
B. False

Section 7 - Arcs, hierarchies, and Recursive Modeling


1. Which of the following can be added to a relationship?
A. An arc can be assigned
B. An optional attribute can be created
C. An attribute
D. A composite attribute

2. Arcs are used to visually represent _________ between two or more relationships in an ERD.
A. Exclusivity
B. Sameness
C. Differences
D. Inheritance

3. An arc can often be modeled as Supertype and Subtypes. True or False?


A. benar
B. Palsu

4. Every business has restrictions on which attribute values and which relationships are allowed.
These are known as:
A. Entities.
B. Relationships
C. Attributes
D. Constraints.

5. Which of the following would best be represented by an arc?


A. DELIVERY ADDRESS (Home, Office)
B. STUDENT (Grade A student, Average Student)
C. PARENT (Girl, Bob)
D. TEACHER (Female, Bob)

6. To visually represent exclusivity between two or more relationships in an ERD you would most
likely use an ________.
A. UID
B. Relationship
C. Arc
D. Attribute
7. Arcs model an Exclusive OR constraint. True or False?
A. benar
B. Palsu

8. Which of the following would best be represented by an arc?


A. STUDENT (Grade A student, Average Student)
B. STUDENT ( University, Technical College)
C. STUDENT (senior, male)
D. STUDENT (graduating, female)

9. A Recursive Relationship is represented on an ERD by a/an:


A. Dog's Tail
B. Single Toe
C. Pig's Ear
D. Crow's Foot

10. A Hierarchical relationship is a series of relationships that reflect entities organized into
successive levels. True or False?
A. benar
B. Palsu

11. A particular problem may be solved using either a Recursive Relationship or a Hierarchical
Relationship, though not at the same time. True or False?
A. benar
B. Palsu

12. A single relationship can be both Recursive and Hierarchical at the same time. True or False?
A. benar
B. Palsu

13. A relationship between an entity and itself is called a/an:


A. Invalid Relationship
B. Heirarchical Relationship
C. Recursive Relationship
D. General Relationship

14. Cascading UIDs are a feature often found in what type of Relationship?
A. General Relationship
B. Invalid Relationship
C. Recursive Relationship
D. Heirarchical Relationship

15. A recursive relationship must be Mandatory at both ends. True or False?


A. benar
B. Palsu

Section 8 - Changes and Historical Modeling


1. Historical data must never be kept. True or False?
A. benar
B. Palsu

2. Which of the following scenarios should be modeled so that historical data is kept? (Choose two)
A. BABY and AGE
B. CUSTOMER and ORDERS
C. TEACHER and AGE
D. CUSTOMER and PAYMENTS

3. Modeling historical data can produce a unique identifier that includes a date. True or False?
A. benar
B. Palsu

4. How do you know when to use the different types of time in your design?
A. Always model time; you can take it out later if it is not needed.
B. It depends on the functional needs of the system .
C. The rules are fixed and should be followed.
D. You would first determine the existence of the concept of time and map it against the
Greenwich Mean Time.

5. There are no circumstances where you would create a DAY entity. True or False?
A. benar
B. Palsu

6. Which of the following would be a logical constraint when modeling time for a country entity?
A. Daily traffic patterns must be monitored to determine which countries are overcrowded.
B. People have births and deaths in their countries that must be tracked by the system.
C. Countries may change their names and/or borders over a period of time.
D. If you are doing a system for France or Germany, you would need security clearance.

7. When you add the concept of time to your data model, your model becomes more complex. True
or False?
A. benar
B. Palsu

8. Conditional non-transferability refers to a relationship that may or may not be transferable,


depending on time. True or False?
A. benar
B. Palsu

9. Formal rules exist for drawing ERD's. You must always follow them, even if it results in an ERD
that is difficult to read. True or False?
A. benar
B. Palsu

10. Which of the following statements are true for ERD's to enhance their readability. (Choose Two)
A. You must ensure that you have every single entity--even if hundreds of them exist--on one
single, big diagram.
B. It is OK to break down a large ERD into subsets of the overall picture. By doing so, you
end up with more than one ERD that, taken together, documents the entire system.
C. Avoid crossing one relationship line with another.
D. The crows feet (many ends) can point whichever way is the easiest to draw.
11. No formal rules exist for drawing ERD's. The most important thing is to make sure that all
entities, attributes, and relationships are documented on the diagram, and the diagram is clear and
readable. True or False?
A. benar
B. Palsu

12. In an ERD, High Volume Entities usually have very few relationships to other entities. True or
False?
A. benar
B. Palsu

13. You are doing a data model for a computer sales company where the price fluctuates on a regular
basis. If you want to allow the company to modify the price and keep track of the changes, what is
the best way to model this?
A. Create a product entity and a related price entity with start and end dates, and then let the
users enter the new price whenever required.
B. Create a new item and a new price every day.
C. Use a price entity with a start and end date
D. Allow them to delete the item and enter a new one.
E. Both A and C

14. When a system requires that old values for attributes are kept on record, this is know as
Journaling or Logging. True or False?
A. benar
B. Palsu

15. Why would you want to model a time component when designing a system that lets people buy
bars of gold?
A. The Government of your country might want to be notified of this transaction.
B. You would not want to model this; it is not important.
C. Sales people must determine where the gold is coming from.
D. The price of gold fluctuates and, to determine the current price, you need to know the
time of purchase.

Section 9 – Mapping
1. In an Oracle database, why would the following table name not be allowed 'EMPLOYEE JOBS'?
A. EMPLOYEE is a reserved word
B. JOBS is a reserved word
C. The database does not understand all capital letters
D. You cannot have spaces between words in a table name

2. The transformation from an ER diagram to a physical design involves changing terminology.


Entities in the ER diagram become __________ :
A. Columns
B. Tables
C. Foreign Keys
D. Unique Keys

3. Why would this table name NOT work in an Oracle database? this_year_end+next_year
A. Table names must begin with an alphabetic character.
B. It is too long.
C. The Plus sign + is not allowed in object names.
D. None of the above.

4. In a physical data model, an attribute becomes a _____________.


A. Foreign Key
B. Table
C. Column
D. Constraint

5. Identify all of the correct statements that complete this sentence: A primary key is: (Choose
Three)
A. Only one column that cannot be null
B. A single column that uniquely identifies each row in a table
C. A set of columns and keys in a single table that uniquely identifies each row in a single
table
D. A set of columns that uniquely identifies each row in a table

6. Foreign keys must be null. True or False?


A. benar
B. Palsu

7. The explanation below is an example of which constraint type?


A column must contain only values consistent with the defined data format of the column
A. User-defined integrity
B. Entity integrity
C. Referential integrity
D. Column integrity

8. Column integrity refers to


A. Columns always containing values consistent with the defined data format
B. Columns always containing text data less than 255 characters
C. Columns always containing positive numbers
D. Columns always having values

9. When translating an arc relationship to a physical design, you must turn the arc relationships into
foreign keys. What additional step must you take with the created foreign keys to ensure the
exclusivity principle of arc relationships? (Assume that you are implementing an Exclusive
Design) (Choose Two)
A. Make all relationships mandatory
B. Make all relationships optional
C. Create an additional check constraint to verify that one foreign key is populated and the
others are not
D. All the above

10. When mapping supertypes, relationships at the supertype level transform as usual. Relationships
at subtype level are implemented as foreign keys, but the foreign key columns all become
mandatory. True or False?
A. benar
B. Palsu

11. Which of the following is a valid reason for considering a Subtype Implementation?
A. The resulting table will reside in a single database and be used by just ONE user.
B. Business functionality, business rules, access paths, and frequency of access are all very
different between the subtypes.
C. Most of the relationships are at the supertype level.
D. The common access paths for the supertypes are different.

12. Relationships on an ERD can only be transformed into UIDs in the physical model? True or
False?
A. benar
B. Palsu

13. An Arc is transformed to the physical model by adding a foreign Key for every relationship in the
Arc. True or False?
A. benar
B. Palsu

14. When an Arc is transformed to the physical model every relationship in the Arc becomes a
mandatory Foreign Key. True or False?
A. benar
B. Palsu

15. In a physical model, many to many relationships are resolved via a structure called a(n):
________________
A. Intersection Entity
B. Subtype
C. Intersection Table
D. Supertype

Section 10 – Creating Database Project


Section 11 – Presenting Database Project
Database Design Final Exam
Section 6
1. There is no limit to how many attributes can make up an entity's UID. True or False?
A. benar
B. Palsu

2. A unique identifier can only be made up of one attribute. True or False?


A. benar
B. Palsu

3. If an entity has no attribute suitable to be a Primary UID, we can create an artificial one. True or
False?
A. benar
B. Palsu

4. A candidate UID that is not chosen to be the Primary UID is called:


A. Artificial
B. Secondary
C. Simple
D. Composite

5. When is an entity in 2nd Normal Form?


A. When all non-UID attributes are dependent upon the entire UID.
B. When attributes with repeating or multi-values are present.
C. When no attritibutes are mutually independent and all are fully dependent on the primary key.
D. None of the Above.
6. Any Non-UID attribute must be dependent upon the entire UID. True or False?
A. benar
B. Palsu

7. Examine the following entity and decide which attribute breaks the 2nd Normal Form rule:
ENTITY: RECEIPT
ATTRIBUTES:
#CUSTOMER ID
#STORE ID
STORE LOCATION
DATE
A. STORE ID
B. CUSTOMER ID
C. DATE
D. STORE LOCATION

8. If an entity has a multi-valued attribute, to conform to the rule of 1st Normal Form we:
A. Create an additional entity and relate it to the original entity with a 1:M relationship.
B. Create an additional entity and relate it to the original entity with a M:M relationship.
C. Do nothing, an entity does not have to be in 1st Normal Form
D. Make the attribute optional

9. An entity ORDER has the attributes Order ID, Order Date, Product id, Customer ID. This entity is
in 1st Normal Form. True or False?
A. benar
B. Palsu

10. When data is only stored in one place in a database, the database conforms to the rules of
___________.
A. Multiplication
B. Reduction
C. Normality
D. Normalization

11. When all attributes are single-valued, the database model is said to conform to:
A. 2nd Normal Form
B. 3rd Normal Form
C. 4th Normal Form
D. 1st Normal Form
12. Examine the following Entity and decide which sets of attributes break the 3rd Normal Form rule:
ENTITY: TRAIN
ATTRIBUTES:
TRAIN ID
MAKE
DRIVER ID
DRIVER NAME
DATE OF MANUFACTURE
A. TRAIN ID, MAKE
B. DRIVER ID, DRIVER NAME
C. MAKE, DATE OF MANUFACTURE
D. None of the above, the entity is already in 3rd Normal Form.

13. The Rule of 3rd Normal Form states that No Non-UID attribute can be dependent on another non-
UID attribute. True or False?
A. benar
B. Palsu

14. As a database designer, you do not need to worry about where in the datamodel you store a
particular attribute; as long as you get it onto the ERD, your job is done. True or False?
A. benar
B. Palsu

15. When any attribute in an entity is dependent on any other non-UID attribute in that entity, this is
known as:
A. Functional dependency
B. Non-dependency
C. Transitive dependency
D. Dependency

Section 7
16. Arcs are used to visually represent _________ between two or more relationships in an ERD.
A. Sameness
B. Differences
C. Exclusivity
D. Inheritance

17. Every business has restrictions on which attribute values and which relationships are allowed.
These are known as:
A. Constraints.
B. Entities.
C. Attributes
D. Relationships
18. Which of the following can be added to a relationship?
A. An attribute
B. An optional attribute can be created
C. A composite attribute
D. An arc can be assigned

19. To visually represent exclusivity between two or more relationships in an ERD you would most
likely use an ________.
A. Attribute
B. Arc
C. Relationship
D. UID

20. A recursive relationship must be Mandatory at both ends. True or False?


A. benar
B. Palsu

21. A single relationship can be both Recursive and Hierarchical at the same time. True or False?
A. benar
B. Palsu

22. A relationship between an entity and itself is called a/an:


A. Invalid Relationship
B. General Relationship
C. Heirarchical Relationship
D. Recursive Relationship

23. A Recursive Relationship is represented on an ERD by a/an:


A. Single Toe
B. Pig's Ear
C. Crow's Foot
D. Dog's Tail

24. A Hierarchical relationship is a series of relationships that reflect entities organized into
successive levels. True or False?
A. benar
B. Palsu

Section 8
25. Historical data must never be kept. True or False?
A. benar
B. Palsu

26. Which of the following scenarios should be modeled so that historical data is kept? (Choose two)
A. TEACHER and AGE
B. BABY and AGE
C. CUSTOMER and ORDERS
D. CUSTOMER and PAYMENTS
27. Which of the following statements are true for ERD's to enhance their readability. (Choose Two)
A. It is OK to break down a large ERD into subsets of the overall picture. By doing so, you end
up with more than one ERD that, taken together, documents the entire system.
B. You must ensure that you have every single entity--even if hundreds of them exist--on one
single, big diagram.
C. Avoid crossing one relationship line with another.
D. The crows feet (many ends) can point whichever way is the easiest to draw.

28. In an ERD, High Volume Entities usually have very few relationships to other entities. True or
False?
A. benar
B. Palsu

29. Modeling historical data is optional. True or False?


A. benar
B. Palsu

30. All systems must have an entity called WEEK with a holiday attribute so that you know when to
give employees a holiday. True or False?
A. benar
B. Palsu

31. You are doing a data model for a computer sales company where the price of postage depends
upon the day of the week that goods are shipped. So shipping is more expensive if the customer
wants a delivery to take place on a Saturday or Sunday. What would be the best way to model
this?
A. Use a Delivery Day entity, which holds prices against week days, and ensure the we also have
an attribute for the Requested Delivery Day in the Order Entity.
B. Update the prices in the system, print out the current prices when they change, and pin them
on the company noticeboard.
C. Allow them to enter whatever delivery charge they want.
D. Email current prices to all employees whenever a price changes.

32. You are doing a data model for a computer sales company where the price fluctuates on a regular
basis. If you want to allow the company to modify the price and keep track of the changes, what is
the best way to model this?
A. Create a product entity and a related price entity with start and end dates, and then let the
users enter the new price whenever required.
B. Create a new item and a new price every day.
C. Use a price entity with a start and end date
D. Allow them to delete the item and enter a new one.
E. Both A and C

Section 9
33. The explanation below is an example of which constraint type?
The value in the dept_no column of the EMPLOYEES table must match a value in the dept_no
column in the DEPARTMENTS table.
A. Referential integrity
B. Column integrity
C. Entity integrity
D. User-defined integrity

34. The explanation below is an example of which constraint type?


A column must contain only values consistent with the defined data format of the column
A. Entity integrity
B. Referential integrity
C. Column integrity
D. User-defined integrity

35. A table should have a primary key. True or False?


A. benar
B. Palsu

36. A foreign key cannot refer to a primary key in the same table. True or False?
A. benar
B. Palsu

37. The explanation below is an example of which constraint type?


A primary key must be unique, and no part of the primary key can be null.
A. Referential integrity
B. Column integrity
C. Entity integrity
D. User-defined integrity

38. Which of the following is a valid reason for considering a Subtype Implementation?
A. Business functionality, business rules, access paths, and frequency of access are all very
different between the subtypes.
B. The resulting table will reside in a single database and be used by just ONE user.
C. Most of the relationships are at the supertype level.
D. The common access paths for the supertypes are different.

39. When translating an arc relationship to a physical design, you must turn the arc relationships into
foreign keys. What additional step must you take with the created foreign keys to ensure the
exclusivity principle of arc relationships? (Assume that you are implementing an Exclusive
Design) (Choose Two)
A. Make all relationships mandatory
B. Make all relationships optional
C. Create an additional check constraint to verify that one foreign key is populated and the others
are not
D. All the above

40. Relationships on an ERD can only be transformed into UIDs in the physical model? True or
False?
A. benar
B. Palsu

41. Two entities A and B have an optional (A) to Mandatory (B) One-to-One relationship. When they
are transformed, the Foreign Key(s) is placed on:
A. The table B
B. Nowhere, One-to-One relationships are not transformed.
C. Both tables A and B get a new column and a Foreign Key.
D. The table A

42. One-to-Many Optional to Mandatory becomes a _______________ on the Master table.


A. Optional Foreign Key
B. Mandatory Foreign Key
C. Primary Key
D. Unique Key

43. In a physical model, many to many relationships are resolved via a structure called a(n):
________________
A. Subtype
B. Intersection Entity
C. Intersection Table
D. Supertype

44. A barrred Relationship will result in a Foreign Key column that also is part of:
A. The Primary Key
B. The Column Name
C. The Table Name
D. The Check Constraint

45. In an Oracle database, why would the following table name not be allowed 'EMPLOYEE JOBS'?
A. You cannot have spaces between words in a table name
B. EMPLOYEE is a reserved word
C. JOBS is a reserved word
D. The database does not understand all capital letters

46. In a physical data model, a relationship is represented as a:


A. Foreign Key
B. Primary Key
C. Column
D. Unique Identifier

47. In a physical data model, an attribute becomes a _____________.


A. Foreign Key
B. Table
C. Constraint
D. Column

48. The Physical model is created by transforming which of the following models?
A. Table
B. Constraint
C. Conceptual
D. Physical

Section 10
49. During which phases of the System Development Life Cycle would you roll out the system to the
users?
A. Transition and Production
B. Design and Production
C. Build and Transition
D. Strategy and Analysis

50. System Documentation is developed right at the end once the system has gone live and users have
been using it for a little while. You are more likely to get it correct that way. True or False?
A. benar
B. Palsu

DP Database Programming with SQL Learner – English


Section 1 – Introduction
1. There is only one kind of software used by all computers. True or False?
A. benar
B. Salah

2. Examine the follolowing SELECT statement.


SELECT *
FROM employees;

This statement will retrieve all the rows in the employees table. True or False?
A. benar
B. Palsu

3. The DESCRIBE command returns all rows from a table. True or False?
A. benar
B. Palsu

4. What command can be used to create a new row in a table in the database?
A. CREATE
B. INSERT
C. NEW
D. ADD

5. All computers in the world speak the same languages, so you only need to learn one programming
language - Oracle SQL. True or False?
A. benar
B. Palsu

6. Most of the well know Internet search engines use databases to store data. True or False?
A. benar
B. Palsu

7. Every time you shop online, it is likely you will be accessing a database. True or False?
A. benar
B. Palsu
8. Every row in a relational database table is unique.
A. benar
B. Palsu

9. A Relational Database generally contains two or more tables. True or False?


A. benar
B. Palsu

10. The basic storage structure in a Relational Database is a _________:


A. Field
B. Key
C. Table
D. Row

11. In the default order of precedence, which operator would be evaluated first?
A. Multiplications and Divisions are at the same level and would be evaluated first based
on left to right order
B. Divisions and Subtractions are at the same level and would be evaluated first based on left to
right order
C. Subtractions and Additions are at the same level and would be evaluated first based on left to
right order
D. Additions and Multiplications are at the same level and would be evaluated first based on left
to right order

12. Evaluate this SELECT statement:


SELECT (salary * raise_percent) raise
FROM employees;
If the RAISE_PERCENT column only contains null values, what will the statement return?
A. Only zeroes
B. Only null values
C. A null value or a zero depending on the value of the SALARY column
D. A null value or a numeric value depending on the value of the SALARY column

13. You query the database with this SQL statement:


SELECT * FROM students;
Why would you use this statement?
A. To delete data
B. To display the table structure
C. To view data
D. To insert data

14. If you want to see just a subset of the columns in a table, you use what symbol?
A. &
B. %
C. *
D. None of the above; instead of using a symbol, you name the columns for which you want
to see data.

15. The SELECT statement retrieves information from the database. In a SELECT statement, you can
do all of the following EXCEPT:
A. Selection
B. Joining
C. Projection
D. Manipulation

Section 2 – Select and Where


1. Which of the following WHERE clauses would not select the number 10?
A. WHERE hours BETWEEN 10 AND 20
B. WHERE hours <>10
C. WHERE hours IN (8,9,10)
D. WHERE hours <= 10

2. When using the "LIKE" operator, the % and _ symbols can be used to do a pattern-matching, wild
card search. True or False?
A. benar
B. Palsu

3. The EMPLOYEES table contains these columns:


LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
EMAIL VARCHAR2(50)
You are writing a SELECT statement to retrieve the names of employees that have an email
address.

SELECT last_name||', '||first_name "Employee Name"


FROM employees;
Which WHERE clause should you use to complete this statement?
A. WHERE email != NULL;
B. WHERE email = NULL;
C. WHERE email IS NOT NULL;
D. WHERE email IS NULL;

4. Which two statements would select salaries that are greater than or equal to 2500 and less than or
equal to 3500? (Choose two)
A. WHERE salary >= 2500 AND salary <= 3500
B. WHERE salary BETWEEN 3500 AND 2500
C. WHERE salary <=2500 AND salary >= 3500
D. WHERE salary BETWEEN 2500 AND 3500
5. If you write queries using the BETWEEN operator, it does not matter in what order you enter the
values, i.e. BETWEEN low value AND high value will give the same result as BETWEEN high
value and low value. True or False?
A. benar
B. Palsu

6. In order to eliminate duplicate rows use the ________ keyword


A. SINGLES_ONLY
B. FIRST_ONLY
C. EXCLUSIVE
D. DISTINCT

7. You need to display employees with salaries that are at least 30000 or higher. Which comparison
operator should you use?
A. !=
B. "=>"
C. >=
D. >

8. The following is a valid SQL SELECT statement. True or False?


SELECT first_name || ' ' || last_name alias AS Employee_Name
FROM employees:
A. Benar
B. Palsu

9. The structure of the table can be displayed with the _________ command:
A. Dis
B. Describe
C. Desc
D. Desc and the Describe

10. Which operator is used to combine columns of character strings to other columns?
A. ||
B. +
C. /
D. *

11. You want to retrieve a list of customers whose last names begin with the letters 'Fr' . Which
symbol should you include in the WHERE clause of your SELECT statement to achieve the
desired result?
A. %
B. #
C. ~
D. *

12. What will be the result of the SELECT statement and what will display?
SELECT last_name, salary, salary + 300
FROM employees;
A. Display the last name, salary, and the results of adding 300 to the salary of the first employee
row
B. Display the last name, salary, and the results of adding 300 to each salary for all the
employees
C. Display the last name and salary of all employees who have a salary greater than 300.
D. Modify the salary column by adding 300 and only display the last name and the new salary.

13. Which of the following is true?


A. Date values are enclosed in single quotation marks
B. Date values are not format-sensitive
C. Character strings must be enclosed in double quotation marks
D. Character values are not case-sensitive

14. How can you write "not equal to" in the WHERE-clause?
A. !=
B. ^=
C. <>
D. All of the above

15. Which example would limit the number of rows returned?


A. SELECT title FROM d_songs WHEN type_code = = 88;
B. SELECT title FROM d_songs WHEN type_code = 88;
C. SELECT title FROM d_songs WHERE type_code = 88;
D. SELECT title FROM d_songs WHERE type_code = = 88;

Section 3 – Where, Order By and Intro to Functions


1. Which of the following best describes the meaning of the LIKE operator?
A. Match a character pattern.
B. To find Null values.
C. Display rows based on a range of values.
D. To test for values in a list.

2. Which of the following are TRUE regarding the logical AND operator?
A. TRUE AND FALSE return FALSE
B. TRUE AND TRUE return FALSE
C. FALSE AND TRUE return NULL
D. TRUE AND FALSE return TRUE

3. Which comparison condition means "Less Than or Equal To"?


A. "=)"
B. ">="
C. "<="
D. "+<"

4. You need to change the default sort order of the ORDER BY clause so that the data is displayed in
reverse alphabetical order. Which keyword should you include in the ORDER BY clause?
A. CHANGE
B. SORT
C. DESC
D. ASC

5. Which of the following would be returned by this SQL statement:


SELECT First_name, last_name, department_id
FROM employees
WHERE department_id IN(50,80)
AND first_name LIKE ' C% '
OR last_name LIKE ' %s% '
A. FIRST_NAME LAST_NAME DEPARTMENT_ID
Shelly Higgins 110
B. FIRST_NAME LAST_NAME DEPARTMENT_ID
Curtis Davies 50
C. FIRST_NAME LAST_NAME DEPARTMENT_ID
Randall Matos 50
D. FIRST_NAME LAST_NAME DEPARTMENT_ID
Michael Hartstein 20
E. All of the above

6. Evaluate this SELECT statement:


SELECT last_name, first_name, department_id, manager_id
FROM employees;
You need to sort data by manager id values and then alphabetically by employee last name and
first name values. Which ORDER BY clause could you use?
A. ORDER BY last_name, first_name, manager_id
B. ORDER BY department_id, last_name
C. ORDER BY manager_id, first_name, last_name
D. ORDER BY manager_id, last_name, first_name

7. Which of the following is true of the ORDER BY clause? (Choose Two)


A. Defaults to a descending order (DESC)
B. Defaults to an ascending order (ASC)
C. Displays the fetched rows in no particular order
D. Must be the last clause of the SQL statement

8. A column alias can be specified in an ORDER BY Clause. True or False?


A. benar
B. Palsu

9. You need to create a report to display all employees that were hired on or before January 1, 1996.
The data should display in this format:
Employee Start Date and Salary
14837 - Smith 10-May-1992 / 5000
Which SELECT statement could you use?
A. SELECT employee_id ||'"- "|| last_name "Employee",
hire_date ||" / "|| salary Start Date and Salary"
FROM employees
WHERE hire_date <= '01-Jan-1996';

B. SELECT employee_id || - || last_name "Employee",


hire_date || / || salary "Start Date and Salary
FROM employees
WHERE hire_date <= '01-Jan-1996';
C. SELECT employee_id ||' - '|| last_name "Employee",
hire_date ||' / '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= '01-Jan-1996';
D. SELECT employee_id ||' '|| last_name "Employee",
hire_date ||' '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= 01-Jan-1996';
E. SELECT employee_id ||' - '|| last_name 'Employee',
hire_date ||' / '|| salary 'Start Date and Salary"
FROM employees
WHERE hire_date <= '01-Jan-1996';

10. You query the database with this SQL statement:


SELECT price
FROM products
WHERE price IN(1, 25, 50, 250)
AND (price BETWEEN 25 AND 40 OR price > 50);

Which two values could the statement return? (Choose two.)


A. 250
B. 50
C. 1
D. 25
E. 10

11. The following statement represents a multi-row function. True or False?


SELECT MAX(salary)
FROM employees
A. benar
B. Palsu

12. The function COUNT is a single row function. True or False?


A. benar
B. Palsu

13. The following statement represents a multi-row function. True or False?


SELECT UPPER(last_name)
FROM employees;
A. benar
B. Palsu

14. The PLAYERS table contains these columns:


PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)
You want to display all players' names with position 6900 or greater.
You want the players names to be displayed alphabetically by last name and then by first name.
Which statement should you use to achieve the required results?
A. SELECT last_name, first_name
FROM players
WHERE position_id >= 6900
ORDER BY last_name DESC, first_name;
B. SELECT last_name, first_name
FROM players
WHERE position_id >= 6900
ORDER BY last_name, first_name;
C. SELECT last_name, first_name
FROM players
WHERE position_id <= 6900
ORDER BY last_name, first_name;
D. SELECT last_name, first_name
FROM players
WHERE position_id > 6900
ORDER BY last_name, first_name;

15. The PLAYERS table contains these columns:


PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)

You must display the player name, team id, and salary for players whose salary is in the
range from 25000 through 100000 and whose team id is in the range of 1200 through
1500. The results must be sorted by team id from lowest to highest and then further sorted
by salary from highest to lowest. Which statement should you use to display the desired
result?
A. SELECT last_name, first_name, team_id, salary
FROM players
WHERE salary > 24999.99 AND salary < 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id ASC, salary DESC;
B. SELECT last_name, first_name, team_id, salary
FROM players
WHERE salary BETWEEN 24999.99 AND 100000.01
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id DESC, salary DESC;
C. SELECT last_name, first_name, team_id, salary
FROM players
WHERE salary BETWEEN 25000 AND 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary DESC;
D. SELECT last_name, first_name, team_id, salary
FROM players
WHERE (salary > 25000 OR salary < 100000)
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary;

Section 4 – Single Row Functions Part I


1. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
A. CONCAT
B. SUBSTR
C. LOWER
D. All three will be evaluated simultaneously.

2. What will the following SQL statemtent display?


SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
A. The last name of employees that have a salary that includes a $ in the value, size of 15 and the
column labeled SALARY.
B. The query will result in an error: "ORA-00923: FROM keyword not found where expected."
C. The last name and the format of the salary limited to 15 digits to the left of the decimal and
the column labeled SALARY.
D. The last name and salary for all employees with the format of the salary 15 characters
long, left-padded with the $ and the column labeled SALARY.

3. What does the following SQL SELECT statement return?


SELECT UPPER( SUBSTR('Database Programming', INSTR('Database Programming','P'),20))
FROM dual;
A. DATABASE
B. Programming
C. PROGRAMMING
D. Database

4. Which character manipulation function always returns a numerical value?


A. TRIM
B. SUBSTR
C. LENGTH
D. LPAD

5. Which of the following SQL statements would correctly return a song title identified in the
database as "All These Years"?
A. WHERE title IN('All','These','Years');
B. WHERE title CONTAINS 'Years';
C. WHERE title LIKE INITCAP('%all these years');
D. WHERE title LIKE LOWER('all these years');

6. Which SELECT statement will return a numeric value?


A. SELECT SYSDATE + 600 / 24
FROM employees;
B. SELECT SYSDATE – 7
FROM employees;
C. SELECT ROUND(hire_date, DAY)
FROM employees;
D. SELECT (SYSDATE - hire_date) / 7
FROM employees;

7. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query
should you issue?
A. SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-Jan-2002 , 31-Jan-2002 )
ORDER BY total;
B. SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-Jan-2002' AND '31-Jan-2002'
ORDER BY total DESC;
C. SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-Jan-2002' AND '01-Jan-2002'
ORDER BY total DESC;
D. SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-Jan-2002' AND '31-Jan-2002'
ORDER BY total DESC;

8. Which function would you use to return the current database server date and time?
A. DATETIME
B. CURRENTDATE
C. SYSDATE
D. DATE

9. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use?
A. BETWEEN
B. MONTHS_BETWEEN
C. ROUND
D. ADD_MONTHS

10. Round and Trunc cannot be used on Date datatypes. True or False?
A. benar
B. Palsu

11. Evaluate this function: MOD (25, 2) Which value is returned?


A. 0
B. 1
C. 2
D. 25

12. Which comparison operator retrieves a list of values?


A. IN
B. BETWEEN IN
C. IS NULL
D. LIKE

13. Which script displays '01-May-2004' when the HIRE_DATE value is '20-May-2004'?
A. SELECT TRUNC(hire_date, 'MI')
FROM employees;
B. SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
C. SELECT ROUND(hire_date, 'MONTH')
FROM employees;
D. SELECT ROUND(hire_date, 'MON')
FROM employees;

14. What is the result of the following SQL Statement:


SELECT ROUND(45.923,-1)
FROM DUAL;

A. 46
B. 45.9
C. 50
D. None of the above

15. You issue this SQL statement:


SELECT TRUNC(751.367,-1) FROM dual;
Which value does this statement display?
A. 700
B. 750
C. 751
D. 751.3

Section 5 – Single Row Functions Part II


1. Which statement will return a listing of last names, salaries, and a rating of 'Low', 'Medium',
'Good' or 'Excellent' depending on the salary value?
A. SELECT last_name,salary,
(CASE WHEN salary<5000 THEN 'Low'
WHEN salary<10000 THEN 'Medium'
WHEN salary<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
B. SELECT last_name,salary,
(CASE WHEN salary<5000 THEN 'Low'
WHEN sal <10000 THEN 'Medium'
WHEN sal <20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
C. SELECT last_name,sal,
(CASE WHEN sal<5000 THEN 'Low'
WHEN sal<10000 THEN 'Medium'
WHEN sal<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
D. SELECT last_name,salary,
(RATING WHEN salary<5000 THEN 'Low'
WHEN salary<10000 THEN 'Medium'
WHEN salary<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
2. CASE and DECODE evaluate expressions in a similar way to IF-THEN-ELSE logic. However,
DECODE is specific to Oracle syntax. True or False?
A. benar
B. Palsu

3. Which of the following is a conditional expression used in SQL?


A. CASE
B. NULLIF
C. DESCRIBE
D. WHERE

4. Which of the following General Functions will return the first non-null expression in the
expression list?
A. NULLIF
B. NVL2
C. COALESCE
D. NVL

5. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and
the HOUSING_BALANCE value is null?
A. SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0),
tutition_balance + housing_balance "Balance Due"
FROM student_accounts;
B. SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
C. SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance +
housing_balance "Balance Due"
FROM student_accounts;
D. SELECT tuition_balance + housing_balance
FROM student_accounts;

6. Consider the following data in the Employees table: (last_name, commission_pct, manager_id)
DATA:
King, null, null
Kochhar, null, 100
Vargas, null, 124
Zlotkey, .2, 100

What is the result of the following statement:


SELECT last_name, COALESCE(commission_pct, manager_id, -1) comm
FROM employees ;
A. King, -1
Kochhar, 100
Vargas, 124
Zlotkey, .2
B. King, null
Kochhar, 100
Vargas, 124
Zlotkey, .2
C. King, -1
Kochhar, 100
Vargas, 124
Zlotkey, 100
D. Statement will fail

7. The STYLES table contains this data:


STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979

Evaluate this SELECT statement:


SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;

Which result will the query provide?


A. STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
B. STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
C. STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
D. STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979

8. Which function compares two expressions?


A. NULL
B. NVL
C. NULLIF
D. NVL2

9. You need to replace null values in the DEPT_ID column with the text N/A. Which functions
should you use?
A. TO_NUMBER and NULLIF
B. TO_CHAR and NVL
C. TO_CHAR and NULL
D. TO_CHAR and NULLIF

10. A table has the following definition: EMPLOYEES(


EMPLOYEE_ID NUMBER(6) NOT NULL,
NAME VARCHAR2(20) NOT NULL,
MANAGER_ID VARCHAR2(6))
and contains the following rows:
(1001, 'Bob Bevan', '200')
(200, 'Natacha Hansen', null)
Will the following query work?

SELECT *
FROM employees
WHERE employee_id = manager_id;
A. Yes, Oracle will perform implicit dataype conversion, and the query will return one row of
data.
B. No, because the datatypes of EMPLOYEE_ID and MANAGER_ID are different.
C. Yes, Oracle will perform implicit datatype conversion, but the WHERE clause will not
find any matching data.
D. No.ᅠ You will have to re-wirte the statement and perform explicit datatype conversion.

11. If you use the RR format when writing a query using the date 27-Oct-17 and the year is 2001,
what year would be the result?
A. 1917
B. 1901
C. 2017
D. 2001

12. The EMPLOYEES table contains these columns:


EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
HIRE_DATE DATE

You need to display HIRE_DATE values in this format:


January 28, 2000
Which SQL statement could you use?
A. SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
B. SELECT TO_CHAR(hire_date, Month DD, YYYY)
FROM employees;
C. SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
D. SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;

13. Which arithmetic operation will return a numeric value?


A. SYSDATE + 30 / 24
B. SYSDATE – 6
C. NEXT_DAY(hire_date) + 5
D. TO_DATE('01-Jun-2004') - TO_DATE('01-Oct-2004')

14. You need to display the HIRE_DATE values in this format: 25th of July 2002. Which SELECT
statement would you use?
A. SELECT TO_CHAR(hire_date, 'DDTH "of" Month YYYY')
FROM employees;
B. SELECT TO_CHAR(hire_date, 'ddth "of" Month YYYY')
FROM employees;
C. SELECT TO_CHAR(hire_date, 'DDspth 'of' Month RRRR')
FROM employees;
D. SELECT enroll_date(hire_date, 'DDspth "of" Month YYYY')
FROM employees;
15. Which statement is true about SQL functions?
A. Functions can convert values or text to another data type.
B. Functions can round a number to a specified decimal place.
C. Functions can convert upper case characters to lower case characters.
D. a, b and c are true.
E. None of the above statements are true.

Section 6 – JOINs Part I


1. For which condition would you use an equijoin query with the USING keyword?
A. The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The
CUST_ID column in the ORDER table contains null values that need to be displayed.
B. You need to perform a join of the CUSTOMER and ORDER tables but limit the
number of columns in the join condition.
C. The CUSTOMER and ORDER tables have no columns with identical names.
D. The ORDER table contains a column that has a referential constraint to a column in the
PRODUCT table.

2. Which keyword in a SELECT statement creates an equijoin by specifying a column name


common to both tables?
A. A HAVING clause
B. The SELECT clause
C. A USING clause
D. The FROM clause

3. Table aliases MUST be used with columns referenced in the JOIN USING clause. True or False?
A. benar
B. Palsu

4. What types of joins will return the unmatched values from both tables in the join?
A. Full outer joins
B. Left outer joins
C. Natural joins
D. Right outer joins

5. Which syntax would be used to retrieve all rows in both the EMPLOYEES and DEPARTMENTS
tables, even when there is no match?
A. LEFT OUTER JOIN AND RIGHT OUTER JOIN
B. FULL OUTER JOIN
C. FULL INNER JOIN
D. Use any equijoin syntax

6. You need to join the EMPLOYEE_HIST and EMPLOYEES tables. The EMPLOYEE_HIST table
will be the first table in the FROM clause. All the matched and unmatched rows in the
EMPLOYEES table need to be displayed. Which type of join will you use?
A. A left outer join
B. A right outer join
C. An inner join
D. A cross join

7. The following statement is an example of what kind of join?


SELECT car.vehicle_id, driver.name
FROM car
LEFT OUTER JOIN driver USING(driver_id) ;
A. Optimal Join
B. Inner Join
C. Equijoin
D. Outer Join

8. Which of the following conditions will cause an error on a NATURAL JOIN?


A. If it selects rows from the two tables that have equal values in all matched columns.
B. If the columns having the same names have different data types.
C. When you attempt to use two tables that have a common field.
D. When the NATURAL JOIN clause is based on all columns in the two tables that have the
same name.

9. A NATURAL JOIN is based on:


A. Columns with the same datatype and width
B. Tables with the same structure
C. Columns with the same name
D. Columns with the same name and datatype
10. You need to join all the rows in the EMPLOYEES table to all the rows in the EMP_REFERENCE
table. Which type of join should you create?
A. A full outer join
B. An equijoin
C. An inner join
D. A cross join

11. Hierarchical queries can walk both Top-Down and Bottom-Up. True or False?
A. benar
B. Palsu

12. Evaluate this SELECT statement:


SELECT * FROM employee worker JOIN employee manager ON worker.mgr_id
=manager.emp_id;
Which type of join is created by this SELECT statement?
A. a full outer join
B. a left outer join
C. a cross join
D. a self join

13. Which SELECT statement implements a self join?


A. SELECT item.part_id, type.product_id
FROM part item JOIN part type ON item.part_id = type.product_id;
B. SELECT item.part_id, type.product_id FROM part item JOIN product type ON item.part_id
=! type.product_id;
C. SELECT item.part_id, type.product_id FROM part item JOIN product type ON item.part_id
= type.product_id (+);
D. SELECT item.part_id, type.product_id FROM part item JOIN product type ON item.part_id
= type.product_id;

14. Hierarchical queries MUST use the LEVEL pseudo column. True or False?
A. benar
B. Palsu

15. Which SELECT statement implements a self join?


A. SELECT worker.employee_id, manager.manager_id
FROM employees worker NATURAL JOIN employees manager;
B. SELECT worker.employee_id, manager.manager_id FROM employees worker JOIN
employees manager ON manager.employee_id = worker.manager_id;
C. SELECT worker.employee_id, manager.manager_id FROM employees worker JOIN
departments manager ON worker.employee_id = manager.manager_id;
D. SELECT worker.employee_id, manager.manager_id FROM employees worker JOIN
managers manager ON worker.employee_id = manager.manager_id;

Section 7 – JOINs Part II


1. The following is a valid outer join statement:
SELECT c.country_name, d.department_name
FROM countries c, departments d
WHERE c.country_id (+) = d.country_id (+)

True or False?
A. benar
B. Palsu

2. The following statement is an example of a nonequi-join?


SELECT e.last_name, e.salary, j.grade_level
FROM employees e, job_grades j
WHERE e.salary
BETWEEN j.lowest_sal AND j.highest_sal;

True or False?
A. benar
B. Palsu

3. Which statement about outer joins is true?


A. The tables must be aliased.
B. Outer joins are always evaluated before other types of joins in the query.
C. The OR operator cannot be used to link outer join conditions.
D. The FULL, RIGHT, or LEFT keyword must be included.

4. You need to join the EMPLOYEES table and the SCHEDULES table, but the two tables do not
have any corresponding columns. Which type of join will you create?
A. It is not possible to join these two tables.
B. A non-equijoin
C. An equijoin
D. A full outer join

5. To perform a valid outer join between DEPARMENTS and EMPLOYEES to list departments
without employees, select the correct WHERE clause for the following select statement:
SELECT d.department_name, e.last_name
FROM employees e, departments d
WHERE
A. e.department_id(+) = d.department_id
B. e.department_id = d.department_id
C. e.department_id(+) = d.department_id(+)
D. e.department_id = d.department_id(+)

6. Which operator is typically used in a nonequijoin?


A. *
B. NOT
C. IN
D. >=, <=, or BETWEEN ...AND
E. OR

7. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID


column of the ORDERS table.
The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you need to
display.
Which type of join should you use to display the data?
A. Natural join
B. Self-join
C. Outer join
D. Equijoin

8. Which statement about the join syntax of an Oracle Proprietary join syntax SELECT statement is
true?
A. The ON keyword must be included.
B. The FROM clause represents the join criteria.
C. The JOIN keyword must be included.
D. The WHERE clause represents the join criteria.

9. Evaluate this SQL statement:


SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;

Which clause contains a syntax error?


A. WHERE e.department_id = d.department_id
B. AND employees.department_id > 5000
C. FROM employees e, departments d
D. SELECT e.employee_id, e.last_name, e.first_name, d.department_name
E. ORDER BY 4;

10. When must column names be prefixed by table names in join syntax?
A. When the same column name appears in more than one table of the query
B. Only when query speed and database performance is a concern
C. When the more than two tables participate in the join
D. Never

11. When joining 3 tables in a SELECT statement, how many join conditions are needed in the
WHERE clause?
A. 2
B. 1
C. 0
D. 3

12. You need to provide a list of the first and last names of all employees who work in the Sales
department who earned a bonus and had sales over $50,000. The company president would like
the sales listed starting with the highest amount first. The EMPLOYEES table and the
SALES_DEPT table contain the following columns:

EMPLOYEES
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPTARTMENT_ID VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)

SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MANAGER VARCHAR2(30)
BONUS NUMBER(10)
EMPLOYEE_ID NUMBER(10) FOREIGN KEY

Which SELECT statement will accomplish this task?

A. SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales


FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
B. SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000;
C. SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.employee_id = s.employee_id AND sales > 50000 AND s.bonus IS NOT NULL;
D. SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
WHERE e.employee_id = s.employee_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;

13. If table A has 10 rows and table B has 5 rows, how many rows will be returned if you perform a
cartesian join on those two tables?
A. 5
B. 50
C. 15
D. 10

14. Oracle proprietary JOINS can use the WHERE clause for conditions other than the join-condition.
True or False?
A. benar
B. Palsu

15. You have two tables named EMPLOYEES and SALES. You want to identify the sales
representatives who have generated at least $100,000 in revenue. Which query should you issue?
A. SELECT first_name, last_name, sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
B. SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
C. SELECT e.first_name, e.last_name, s.sales
FROM employees, sales
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
D. SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
Section 8 – Group Functions Part I
1. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM products;

Which statement is true?


A. The number of rows in the table is displayed.
B. An error occurs because no WHERE clause is included in the SELECT statement.
C. An error occurs due to an error in the SELECT clause.
D. The number of unique PRODUCT_IDs in the table is displayed.

2. Evaluate this SELECT statement:


SELECT COUNT(*)
FROM employees
WHERE salary > 30000;

Which result will the query display?


A. The number of rows in the EMPLOYEES table that have a salary greater than 30000
B. The number of employees that have a salary less than 30000
C. The total of the SALARY column for all employees that have a salary greater than 30000
D. The query generates an error and returns no results.

3. Which statement about the COUNT function is true?


A. The COUNT function can be used to find the maximum value in each column.
B. The COUNT function can be used to determine the number of unique, non-null values in a
column.
C. The COUNT function ignores duplicates by default.
D. The COUNT function always ignores null values by default.

4. Given the following data in the employees table (employee_id, salary, commission_pct) DATA:
(143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)

What is the result of the following statement:

SELECT SUM(commission_pct), COUNT(commission_pct)


FROM employees
WHERE employee_id IN( 143,144,149,174,176,178);
A. SUM = 1.85 and COUNT = 4
B. SUM = 1.85 and COUNT = 6
C. SUM = .85 and COUNT = 6
D. SUM = .85 and COUNT = 4
5. What would the following SQL statement return?
SELECT COUNT(first_name) FROM employees;
A. The total number of rows in the employees table
B. A listing of all unique first names in the employees table
C. A listing of all non-null first names in the employees table
D. The total number of non-null first names in the employees table

6. To include null values in the calculations of a group function, you must:


A. Group functions can never use null values
B. Convert the null to a value using the NVL( ) function
C. Precede the group function name with NULL
D. Count the number of null values in that column using COUNT

7. The STYLES table contains this data:

STYLE_ID STYLE_NAME CATEGORY COST


895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
A. 7
B. 6
C. 0
D. The statement will NOT execute successfully.

8. You need to calculate the average salary of employees in each department. Which group function
will you use?
A. AVERAGE
B. MEAN
C. MEDIAN
D. AVG
9. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATEPAYMENT_TYPE PAYMENT_AMOUNT

86590586 8908090 10-Jun-2003 BASIC 859.00

89453485 8549038 15-Feb-2003 INTEREST 596.00

85490345 5489304 20-Mar-2003 BASIC 568.00

You need to determine the average payment amount made by each customer in January, February,
and March of 2003.
Which SELECT statement should you use?
A. SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-Jan-2003' and '31-Mar-2003';
B. SELECT AVG(payment_amount)
FROM payment;
C. SELECT AVG(payment_amount)
FROM payment WHERE payment_date
BETWEEN '01-Jan-2003' AND '31-Mar-2003';
D. SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (Jan, Feb, Mar);

10. The TRUCKS table contains these columns:


TRUCKS:
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)

Which SELECT statement will return the average price for the 4x4 model?
A. SELECT AVG(price), model FROM trucks
WHERE model IS '4x4';
B. SELECT AVG(price) FROM trucks
WHERE model IS 4x4;
C. SELECT AVG(price) FROM trucks
WHERE model = '4x4';
D. SELECT AVG(price) FROM trucks
WHERE model IS '4x4';

11. Given the following data in the employees table (employee_id, salary, commission_pct) DATA:
(143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)

What is the result of the following statement:


SELECT AVG(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178);
A. 0.2125
B. 1.2125
C. 0.0425
D. This statement is invalid

12. The following statement will work, even though it contains more than one GROUP function:
SELECT AVG(salary), MAX(salary), MIN(salary), SUM(salary)
FROM employees;

True or False?
A. benar
B. Palsu

13. Which group function would you use to display the average price of all products in the
PRODUCTS table?
A. MAX
B. COUNT
C. AVG
D. SUM

14. The PRODUCTS table contains these columns:


PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)

The following statement is issued:


SELECT AVG(prod_price, prod_qty)
FROM products;

What happens when this statement is issued?


A. Both the average price and the average quantity of the products are returned.
B. An error occurs.
C. Only the average quantity of the products is returned.
D. The values in the PROD_PRICE column and the PROD_QTY column are averaged together.

15. What two group functions can be used with any datatype?
A. MIN, MAX
B. COUNT, SUM
C. SUM, AVG
D. STDDEV, VARIANCE
Section 9 – Group Functions Part II
1. When using SET operators, the names of the matching columns must be identical in all of the
SELECT statements used in the query. True or False?
A. True
B. False

2. The difference between UNION and UNION ALL is


A. There is no difference; you get exactly the same result from both.
B. UNION is a synomym for UNION ALL.
C. UNION ALL is more like a NATURAL JOIN.
D. UNION will remove duplicates; UNION ALL returns all rows from all queries including
the duplicates.

3. When using SET operators, the number of columns and the data types of the columns must be
identical in all of the SELECT statements used in the query. True or False.
A. True
B. False

4. You use GROUPING functions to:


A. Identify the extra row values created by either a ROLLUP or CUBE operation
B. Produce subtotal and cross-tabulated values
C. Aggregate rows using SUM, MIN, MAX, and COUNT

5. Examine the following statement:


SELECT department_id, manager_id, job_id, SUM(salary)
FROM employees
GROUP BY GROUPING SETS((department_id, manager_id), (department_id, job_id))

What data will this query generate?


A. Sum of salaries for (department_id, job_id) and (department_id, manager_id)
B. Sum of salaries for (department_id, job_id, manager_id)
C. Subtotals for (job_id, manager_id)
D. The statement will fail.

6. CUBE will cross-reference the columns listed in the ______ clause to create a superset of groups.
A. WHERE
B. GROUP BY
C. SELECT

7. GROUPING SETS is another extension to the GROUP BY clause and is used to specify multiple
groupings of data but provide a single result set. True or False?
A. True
B. False

8. Examine the following statement:


SELECT department_id, manager_id, job_id, SUM(salary)
FROM employees
GROUP BY GROUPING SETS(.......);

Select the correct GROUP BY GROUPING SETS clause from the following list:
A. GROUP BY GROUPING SETS ((department_id, manager_id), (department_id,
SUM(salary), (manager_id, job_id))
B. GROUP BY GROUPING SETS (department_id, salary), (department_id, job_id),
(department_id, manager_id)
C. GROUP BY GROUPING SETS ((department_id, manager_id), (department_id,
job_id), (manager_id, job_id))
D. GROUP BY GROUPING SETS (department_id, AVG(salary)), (department_id, job_id),
(department_id, manager_id)

9. If you want to include subtotals and grand totals for all columns mentioned in a GROUP BY
clause, you should use which of the following extensions to the GROUP BY clause?
A. HAVING
B. GROUP BY ALL COLUMNS
C. ROLLUP
D. CUBE

10. Evaluate this statement:


SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;

Which clauses restricts the result? Choose two.


A. HAVING AVG(salary) > 35000
B. WHERE job_id <> 69879
C. SELECT department_id, AVG(salary)
D. GROUP BY job_id, department_id

11. The PLAYERS table contains these columns:


PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)

Which clauses represent valid uses of aggregate functions? (Choose three.)


A. ORDER BY AVG(salary)
B. HAVING MAX(salary) > 10000
C. WHERE hire_date > AVG(hire_date)
D. SELECT AVG(NVL(salary, 0))
E. GROUP BY MAX(salary)

12. If a select list contains both a column as well as a group function then what clause is required?
A. GROUP BY clause
B. HAVING clause
C. ORDER BY clause
D. JOIN clause
13. Evaluate this SELECT statement:
SELECT MAX(salary), department_id
FROM employees
GROUP BY department_id;

Which values are displayed?


A. The employees with the highest salaries
B. The employee with the highest salary for each department
C. The highest salary in each department
D. The highest salary for all employees

14. Is the following statement correct?


SELECT first_name, last_name, salary, department_id, COUNT(employee_id)
FROM employees
WHERE department_id = 50
GROUP BY last_name, first_name, department_id;
A. Yes, because Oracle will correct any mistakes in the statement itself
B. Yes
C. No, beause you cannot have a WHERE-clause when you use group functions.
D. No, because the statement is missing salary in the GROUP BY clause

15. The EMPLOYEES table contains these columns:


ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE

Evaluate this SQL statement:

SELECT id_number, name, department_id, SUM(salary)


FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;

Why will this statement cause an error?


A. The WHERE clause contains a syntax error.
B. The HAVING clause is missing.
C. The SALARY column is NOT included in the GROUP BY clause.
D. The HIRE_DATE column is NOT included in the GROUP BY clause.

Section 10 – Subqueries
1. The WITH clause enables a SELECT statement to define the subquery block at the start of the
query, process the block just once, label the results, and then refer to the results multiple times.
True or False?
A. True
B. False
2. In a correlated subquery, the outer and inner queries are joined on one or more columns. (True or
False?)
A. benar
B. Palsu

3. When creating a report of all employees earning more than the average salary for their
department, a __________ ____________ can be used to first calculate the average salary of each
department, and then compare the salary for each employee to the average salary of that
employee's department.
A. GROUP BY
B. CORRELATED SUBQUERY
C. WITH CLAUSE

4. Subqueries can only be placed in the WHERE clause. True or False?


A. benar
B. Palsu

5. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:


TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ID NUMBER(5)

CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
DATE
MAX_CAPACITY NUMBER (3)

All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two.)
A. SELECT * FROM teachers
WHERE teacher_id LIKE
(SELECT teacher_id FROM class_assignments WHERE max_capacity > 1000);
B. SELECT * FROM teachers
WHERE teacher_id = (SELECT teacher_id, class_assignments WHERE max_capacity > 0);
C. SELECT * FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id
= 45963);
D. SELECT * FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
E. SELECT * FROM class_assignments
max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);

6. What will the following statement return:


SELECT employee_id, last_name FROM employees
WHERE salary = (SELECT MIN(salary)
FROM employees
GROUP BY department_id);
A. A list of last_names and salaries of employees
B. Nothing. It is an invalid statement.
C. A list of last_names and salaries of employees grouped by department_id.
D. A list of first_names and salaries of employees in Department 50

7. Which comparison operator can only be used with a single-row subquery?


A. IN
B. <>
C. ANY
D. ALL

8. You need to produce a report that contains all employee-related information for those employees
who have Brad Carter as a supervisor. However, you are not sure which supervisor ID belongs to
Brad Carter. Which query should you issue to accomplish this task?
A. SELECT * FROM employees WHERE supervisor_id =
(SELECT supervisor_id FROM employees
WHERE last_name = 'Carter');
B. SELECT * FROM supervisors WHERE supervisor_id =
(SELECT employee_id FROM supervisors
WHERE last_name = 'Carter');
C. SELECT * FROM employees WHERE supervisor_id =
(SELECT employee_id FROM employees
WHERE last_name = 'Carter');
D. SELECT * FROM supervisors WHERE supervisor_id =
(SELECT supervisor_id FROM employees
WHERE last_name = 'Carter');

9. Which statement about the <> operator is true?


A. The <> operator can be used when a single-row subquery returns only one row.
B. The <> operator is NOT a valid SQL operator.
C. The <> operator returns the same result as the ANY operator in a subquery.
D. The <> operator CANNOT be used in a single-row subquery.

10. Which best describes a multiple-row subquery?


A. A query that returns one or more rows from the inner SELECT statement
B. A query that returns only one row from the inner SELECT statement
C. A query that returns one or more column values from the inner SELECT statement
D. A query that returns only one column value from the inner SELECT statement

11. The SQL multiple-row subquery extends the capability of the single-row syntax through the use
of which three comparison operators?
A. IN, ANY, and EQUAL
B. IN, ALL, and EVERY
C. IN, ANY, and EVERY
D. IN, ANY, and ALL

12. Group functions can be used in multiple-row subqueries in the HAVING and GROUP BY clauses.
True or False?
A. benar
B. Palsu
13. You are looking for Executive information using a subquery.
What will the following SQL statement display?

SELECT department_id, last_name, job_id


FROM employees
WHERE department_id IN
(SELECT department_id FROM departments WHERE department_name = 'Executive');
A. The department ID, last name, and job ID for every employee in the Executive
department
B. The department ID, last name, and department name for every Executive in the employees
table
C. The department ID, last name, and job ID from departments for Executive employees
D. The department ID, department name, and last name for every employee in the Executive
department

14. Which of the following statements contains a comparison operator that is used to restrict rows
based on a list of values returned from an inner query?
A. SELECT description FROM d_types
WHERE code IN (
SELECT type_code FROM d_songs);
B. SELECT description FROM d_types
WHERE code = ANY (
SELECT type_code FROM d_songs);
C. SELECT description FROM d_types
WHERE code <> ALL (
SELECT type_code FROM d_songs);
D. All of the above.

15. Group functions can be used in subqueries even though they may return many rows. True or
False?
A. benar
B. Palsu

Database Programming with SQL Midterm Exam


Section 1
1. Evaluate this SELECT statement:
SELECT (salary * raise_percent) raise
FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return?
A. A null value or a zero depending on the value of the SALARY column
B. A null value or a numeric value depending on the value of the SALARY column
C. Only null values
D. Only zeroes

2. You want to create a list of all albums that have been produced by the company. The list should
include the title of the album, the artist's name, and the date the album was released. The
ALBUMS table includes the following columns:

ALB_TITLE VARCHAR2(150) NOT NULL


ALB_ARTIST VARCHAR2(150) NOT NULL
ALB_DATE DATE NOT NULL

Which statement can you use to retrieve the necessary information?


A. SELECT alb_title, alb_artist, alb_dates FROM albums;
B. SELECT alb_title; alb_artist; alb_date FROM albums;
C. SELECT * FROM albums;
D. SELECT alb_title, alb_artist, alb_dates FROM album;

3. In the real world, databases used by businesses generally have a single table . True or False?
A. benar
B. Palsu

4. What command can be added to a select statement to return a subset of the data?
A. WHEN
B. WHERE
C. EVERYONE
D. ALL

5. What command can be used to create a new row in a table in the database?
A. CREATE
B. ADD
C. INSERT
D. NEW

Section 2
6. Which of the following WHERE clauses would not select the number 10?
A. WHERE hours <>10
B. WHERE hours BETWEEN 10 AND 20
C. WHERE hours IN (8,9,10)
D. WHERE hours <= 10

7. If you write queries using the BETWEEN operator, it does not matter in what order you enter the
values, i.e. BETWEEN low value AND high value will give the same result as BETWEEN high
value and low value. True or False?
A. benar
B. Palsu

8. Which operator is used to combine columns of character strings to other columns?


A. ||
B. *
C. +
D. /

9. You need to display only unique combinations of the LAST_NAME and MANAGER_ID
columns in the EMPLOYEES table. Which keyword should you include in the SELECT clause?
A. DISTINCT
B. UNIQUEONE
C. DISTINCTROW
D. ONLY

10. Which of the following is true?


A. Character values are not case-sensitive
B. Character strings must be enclosed in double quotation marks
C. Date values are not format-sensitive
D. Date values are enclosed in single quotation marks

11. Which example would limit the number of rows returned?


A. SELECT title FROM d_songs WHEN type_code = 88;
B. SELECT title FROM d_songs WHEN type_code = = 88;
C. SELECT title FROM d_songs WHERE type_code = 88;
D. SELECT title FROM d_songs WHERE type_code = = 88;
E.

Section 3
12. Which clause would you include in a SELECT statement to sort the rows returned by the
LAST_NAME column?
A. WHERE
B. ORDER BY
C. HAVING
D. FROM

13. You need to create a report to display all employees that were hired on or before January 1, 1996.
The data should display in this format:
Employee Start Date and Salary
14837 - Smith 10-May-1992 / 5000

Which SELECT statement could you use?


A. SELECT employee_id ||' - '|| last_name 'Employee', hire_date ||' / '|| salary 'Start Date and
Salary"
FROM employees
WHERE hire_date <= '01-Jan-1996';
B. SELECT employee_id || - || last_name "Employee", hire_date || / || salary "Start Date and
Salary
FROM employees
WHERE hire_date <= '01-Jan-1996';
C. SELECT employee_id ||' - '|| last_name "Employee", hire_date ||' / '|| salary "Start Date and
Salary"
FROM employees
WHERE hire_date <= '01-Jan-1996';
D. SELECT employee_id ||'"- "|| last_name "Employee", hire_date ||" / "|| salary Start Date and
Salary"
FROM employees
WHERE hire_date <= '01-Jan-1996';
E. SELECT employee_id ||' '|| last_name "Employee", hire_date ||' '|| salary "Start Date and
Salary"
FROM employees
WHERE hire_date <= 01-Jan-1996';
14. Which SELECT statement should you use to limit the display of product information to those
products with a price of less than 50?
A. SELECT product_id, product_name
FROM products
WHERE price < 50.00
GROUP BY price;
B. SELECT product_id, product_name
FROM products
WHERE price < 50;
C. SELECT product_id, product_name
FROM products
WHERE price <= 50;
D. SELECT product_id, product_name
FROM products
HAVING price < 50;
E. SELECT product_id, product_name
FROM products
GROUP BY price < 50;

15. Will the following statement return one row?


SELECT MAX(salary), MIN(Salary), AVG(SALARY)
FROM employees;
A. Yes, it will return the average salary from the employees table.
B. Yes, it will return the highest salary, the lowest salary, and the average salary from all
employees.
C. Yes, it will return the highest salary from each employee.
D. No, it is illegal. You cannot use more than one multi-row function in a SELECT statement.

Section 4
16. What does the following SQL SELECT statement return?
SELECT UPPER( SUBSTR('Database Programming', INSTR('Database Programming','P'),20))
FROM dual;
A. DATABASE
B. PROGRAMMING
C. Programming
D. Database

17. The STYLES table contains this data:


STYLE_ID STYLE_NAME CATEGORY COST

895840 SANDAL 85940 12.00


968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00

You query the database and return the value 79. Which script did you use?
A. SELECT INSTR(category, -2,2) FROM styles
WHERE style_id = 895840;
B. SELECT SUBSTR(category, -2,2) FROM styles
WHERE style_id = 758960;
C. SELECT INSTR(category, 2,2) FROM styles
WHERE style_id = 895840;
D. SELECT SUBSTR(category, 2,2) FROM styles
WHERE style_id = 895840;

18. Which comparison operator retrieves a list of values?


A. IS NULL
B. BETWEEN IN
C. LIKE
D. IN

19. Which query would return a whole number if the sysdate is 26-May-2004?
A. SELECT TRUNC(MONTHS_BETWEEN(SYSDATE,'19-Mar-1979') /12)
AS YEARS FROM DUAL;
B. SELECT TRUNC(YEARS_BETWEEN(SYSDATE,'19-Mar-1979') /12)
AS YEARS FROM DUAL;
C. SELECT MONTHS_BETWEEN(SYSDATE,'19-Mar-1979') /12 AS YEARS
FROM DUAL;
D. None of the above

Section 5
20. Which statement will return a listing of last names, salaries, and a rating of 'Low', 'Medium',
'Good' or 'Excellent' depending on the salary value?
A. SELECT last_name,sal,
(CASE WHEN sal<5000 THEN 'Low'
WHEN sal<10000 THEN 'Medium'
WHEN sal<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
B. SELECT last_name,salary,
(CASE WHEN salary<5000 THEN 'Low'
WHEN salary<10000 THEN 'Medium'
WHEN salary<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
C. SELECT last_name,salary,
(CASE WHEN salary<5000 THEN 'Low'
WHEN sal <10000 THEN 'Medium'
WHEN sal <20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
D. SELECT last_name,salary,
(RATING WHEN salary<5000 THEN 'Low'
WHEN salary<10000 THEN 'Medium'
WHEN salary<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;

21. If quantity is a number datatype, what is the result of this statement?


SELECT NVL(200/quantity, 'zero') FROM inventory;
A. ZERO
B. The statement fails
C. Null
D. Zero

22. Which of the following General Functions will return the first non-null expression in the
expression list?
A. COALESCE
B. NVL
C. NULLIF
D. NVL2

23. Which statement concerning single row functions is true?


A. Single row functions can be nested.
B. Single row functions can accept only one argument, but can return multiple values.
C. Single row functions return one or more results per row.
D. Single row functions cannot modify a data type.

24. A table has the following definition: EMPLOYEES(


EMPLOYEE_ID NUMBER(6) NOT NULL,
NAME VARCHAR2(20) NOT NULL,
MANAGER_ID VARCHAR2(6))

and contains the following rows:


(1001, 'Bob Bevan', '200')
(200, 'Natacha Hansen', null

Will the following query work?


SELECT * FROM employees
WHERE employee_id = manager_id;
A. Yes, Oracle will perform implicit datatype conversion, but the WHERE clause will not find
any matching data.
B. No.ᅠ You will have to re-wirte the statement and perform explicit datatype conversion.
C. Yes, Oracle will perform implicit dataype conversion, and the query will return one row of
data.
D. No, because the datatypes of EMPLOYEE_ID and MANAGER_ID are different.

25. The following script will run successfully. True or False?


SELECT TO_CHAR(TO_DATE('25-Dec-2004','dd-Mon-yyyy'))
FROM dual
A. benar
B. Palsu

Section 6
26. Which select statement will return the last name and hire date of an employee and his/ her
manager for employees that started in the company before their managers?
A. SELECT worker.last_name, worker.hire_date, manager.last_name, manager.hire_date
FROM employees worker JOIN employees manager ON worker.manager_id !=
manager.employee_id
WHERE worker.hire_date < manager.hire_date
B. SELECT worker.last_name, worker.hire_date, manager.last_name, manager.hire_date
FROM employees worker JOIN employees worker ON worker.manager_id =
worker.employee_id
WHERE worker.hire_date < worker.hire_date
C. SELECT worker.last_name, worker.hire_date, manager.last_name, manager.hire_date
FROM employees worker JOIN employees manager ON worker.manager_id =
manager.employee_id
WHERE worker.hire_date > manager.hire_date
D. SELECT worker.last_name, worker.hire_date, manager.last_name, manager.hire_date
FROM employees worker JOIN employees manager ON worker.manager_id =
manager.employee_id
WHERE worker.hire_date < manager.hire_date

27. Which SELECT statement implements a self join?


A. SELECT item.part_id, type.product_id
FROM part item JOIN product type
ON item.part_id = type.product_id;
B. SELECT item.part_id, type.product_id
FROM part item JOIN product type
ON item.part_id =! type.product_id;
C. SELECT item.part_id, type.product_id
FROM part item JOIN part type
ON item.part_id = type.product_id;
D. SELECT item.part_id, type.product_id
FROM part item JOIN product type
ON item.part_id = type.product_id (+);

28. Which query represents the correct syntax for a left outer join?
A. SELECT companyname, orderdate, total
FROM customers
LEFT JOIN orders
ON customers.cust_id = orders.cust_id;
B. SELECT companyname, orderdate, total
FROM customers
LEFT OUTER orders
ON customers.cust_id = orders.cust_id;
C. SELECT companyname, orderdate, total
FROM customers
LEFT OUTER JOIN orders
ON customers.cust_id = orders.cust_id;
D. SELECT companyname, orderdate, total
FROM customers
OUTER JOIN orders
ON customers.cust_id = orders.cust_id;

29. EMPLOYEES Table:


Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
DEPARTMENT_ID NUMBER (4)

DEPARTMENTS Table:
Name Null? Type
DEPARTMENT_ID NOT NULL NUMBER 4
DEPARTMENT_NAME NOT NULL VARCHAR2(30)
MANAGER_ID NUMBER (6)

A query is needed to display each department and its manager name from the above tables.
However, not all departments have a manager but we want departments returned in all cases.
Which of the following SQL: 1999 syntax scripts will accomplish the task?
A. SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees , departments
WHERE employees.employee_id
RIGHT OUTER JOIN departments.manager_id;
B. SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees
RIGHT OUTER JOIN departments
ON (employees.employee_id = departments.manager_id);
C. SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees
LEFT OUTER JOIN departments
WHERE (employees.department_id = departments.department_id);
D. SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees
FULL OUTER JOIN departments
ON (employees.employee_id = departments.manager_id);

30. Which of the following conditions will cause an error on a NATURAL JOIN?
A. If it selects rows from the two tables that have equal values in all matched columns.
B. When you attempt to use two tables that have a common field.
C. When the NATURAL JOIN clause is based on all columns in the two tables that have the
same name.
D. If the columns having the same names have different data types.

31. The join column must be included in the select statement when you use the NATURAL JOIN
clause. True or False?
A. benar
B. Palsu
C.
32. Below find the structures of the PRODUCTS and VENDORS tables:
PRODUCTS
PRODUCT_ID NUMBER
PRODUCT_NAME VARCHAR2 (25)
VENDOR_ID NUMBER
CATEGORY_ID NUMBER

VENDORS
VENDOR_ID NUMBER
VENDOR_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)

You want to create a query that will return an alphabetical list of products, including the product
name and associated vendor name, for all products that have a vendor assigned.

Which two queries could you use?


A. SELECT products.product_name, vendors.vendor_name
FROM products
NATURAL JOIN vendors
ORDER BY products.product_name;
B. SELECT products.product_name, vendors.vendor_name
FROM products
JOIN vendors
ON (vendor_id)
ORDER BY prodcuts.product_name;
C. SELECT products.product_name, vendors.vendor_name
FROM products
LEFT OUTER JOIN vendors
ON products.vendor_id = vendors.vendor_id
ORDER BY products.product_name;
D. SELECT products.product_name, vendors.vendor_name
FROM products
JOIN vendors
USING (products.vendor_id)
ORDER BY products.product_name;
E. SELECT products.product_name, vendors.vendor_name
FROM products
JOIN vendors
USING (vendor_id)
ORDER BY products.product_name;

Section 7
33. The ID column in the CLIENT table that corresponds to the CLIENT_ID column of the ORDER
table contains null values for rows that need to be displayed. Which type of join should you use to
display the data?
A. Outer join
B. Self join
C. Equijoin
D. Nonequi-Join

34. The CUSTOMERS and SALES tables contain these columns:


CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)

SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)

Which SELECT statement will return the customer ID, the company and the total sales?
A. SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
B. SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
C. SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
D. SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;

35. What is the result of a query that selects from two tables but includes no join condition?
A. A selection of rows from the first table only
B. A syntax error
C. A Cartesian product
D. A selection of matched rows from both tables

Section 8
36. Evaluate this SQL statement:
SELECT COUNT (amount) FROM inventory;
What will occur when the statement is issued?
A. The statement will replace all NULL values that exist in the AMOUNT column.
B. The statement will return the greatest value in the INVENTORY table.
C. The statement will count the number of rows in the INVENTORY table where the AMOUNT
column is not null.
D. The statement will return the total number of rows in the AMOUNT column.

37. You need to calculate the average salary of employees in each department. Which group function
will you use?
A. MEDIAN
B. AVERAGE
C. AVG
D. MEAN
38. Group functions return a value for ________________ and ________________ null values in
their computations.
A. each row, include
B. a row set, include
C. each row, ignore
D. a row set, ignore

Section 9
39. When using SET operators, the names of the matching columns must be identical in all of the
SELECT statements used in the query. True or False?
A. True
B. False

40. Group functions can be nested to a depth of?


A. Group functions cannot be nested.
B. Four
C. Two
D. Three

41. How would you alter the following query to list only employees where two or more employees
have the same last name?
A. SELECT last_name, COUNT(employee_id)
FROM EMPLOYEES
GROUP BY last_name;
B. SELECT last_name, COUNT(employee_id)
FROM EMPLOYEES
WHERE COUNT(*) > 1
GROUP BY last_name
C. SELECT employee_id, DISTINCT(last_name)
FROM EMPLOYEES
GROUP BY last_name
HAVING last_name > 1;
D. SELECT last_name, COUNT(last_name)
FROM EMPLOYEES
GROUP BY last_name
EXISTS COUNT(last_name) > 1;
E. SELECT last_name, COUNT(last_name)
FROM EMPLOYEES
GROUP BY last_name
HAVING COUNT(last_name) > 1;
The EMPLOYEES table contains the following columns:

42. EMPLOYEE_ID NUMBER(10) PRIMARY KEY


LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)

You want to create a report that includes each employee's last name, employee identification
number, date of hire, and salary. The report should include only those employees who have been
with the company for more than one year and whose salary exceeds $40,000.

Which of the following SELECT statements will accomplish this task?


A. SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date =
(SELECT hire_date
FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
B. SELECT employee_id, last_name, hire_date, salary
FROM employees
WHERE salary > 40000 AND hire_date =
(SELECT hire_date
FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
C. SELECT employee_id, last_name, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
D. SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);

43. You use ROLLUP to:


A. cross-tabulate values
B. produce subtotal values
C. produce a single result set

44. You use GROUPING functions to ______ database rows from tabulated rows.
A. COUNT
B. DISTINGUISH
C. CREATE
D. COMPUTE
Section 10
45. Which best describes a multiple-row subquery?
A. A query that returns only one row from the inner SELECT statement
B. A query that returns one or more rows from the inner SELECT statement
C. A query that returns one or more column values from the inner SELECT statement
D. A query that returns only one column value from the inner SELECT statement

46. What is wrong with the following query?


SELECT employee_id, last_name
FROM employees
WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id);
A. Nothing, it will run without problems.
B. Subquery returns more than one row and single row comparison operator is used.
C. Subquery references the wrong table in the WHERE clause.
D. Single rows contain multiple values and a logical operator is used.

47. Which of the following is a valid reason why the query below will not execute successfully?
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id = (SELECT department_id FROM employees WHERE last_name like
'%u%');
A. A single, rather than a multiple value operator was used.
B. Second subquery found on the right instead of the left side of the operator.
C. First subquery not enclosed in parentheses.
D. The greater than operator is not valid.

48. You need to display all the players whose salaries are greater than or equal to John Brown's salary.
Which comparison operator should you use?
A. >=
B. <=
C. =
D. >

49. The result of this statement will be:


SELECT last_name, job_id, salary, department_id FROM employees
WHERE job_id = (SELECT job_id
FROM employees
WHERE employee_id = 141) AND department_id = (SELECT department_id
FROM departments
WHERE location_id =1500);
A. All employees from Location 1500 will be displayed
B. An error since you canメt get data from two tables in the same subquery
C. All employees with the department id of 141
D. Only the employees whose job id matches employee 141 and who work in location 1500

50. A correlated subquery is evaluated _____ for each row processed by the parent statement.
A. ONCE
B. EVERY TIME
C. COMPLETELY
Section 11 - Ensuring Quality Queries Part I
Section 12 – DML
1. You want to enter a new record into the CUSTOMERS table. Which two commands can be used
to create new rows?
A. INSERT, CREATE
B. MERGE, CREATE
C. INSERT, MERGE
D. INSERT, UPDATE

2. When the WHERE clause is missing in a DELETE statement, what is the result?
A. All rows are deleted from the table.
B. An error message is displayed indicating incorrect syntax.
C. The table is removed from the database.
D. Nothing. The statement will not execute.

3. To change an existing row in a table, you can use the UPDATE or INSERT statements. True or
False?
A. benar
B. Palsu

4. What keyword in an UPDATE statement specifies the column that you want to change?
A. WHERE
B. SET
C. HAVING
D. SELECT

5. DELETE statements can use correlated subqueries? (True or False)


A. benar
B. Palsu

6. A DEFAULT value can be specified for a column when the table is created. True or false?
A. benar
B. Palsu

7. Using MERGE accomplishes an __________ and __________ simultaneously.


A. INSERT; UPDATE
B. UPDATE; DELETE
C. UPDATE; SELECT
D. INSERT; SELECT

8. A multi-table insert statement must have a subquery at the end of the statement. (True or False?)
A. benar
B. Palsu

9. The MERGE statement first tries to update one or more rows in a table that match the criteria; if
no row matches the criteria for the update, a new row will automatically be inserted instead. True
or False?
A. benar
B. Palsu
10. Multi-table inserts are used when the same source data should be inserted into _____________
target table.
A. More than one
B. A very large
C. Ten
D. A data warehouse

11. The STUDENTS table contains these columns:


STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE

You create another table, named FT_STUDENTS, with an identical structure.You want to insert
all full-time students who have a STU_TYPE_ID value of "F" into the new table. You execute this
INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');

What is the result of executing this INSERT statement?


A. An error occurs because the FT_STUDENTS table already exists.
B. All full-time students are inserted into the FT_STUDENTS table.
C. An error occurs because the INSERT statement does NOT contain a VALUES clause.
D. An error occurs because you CANNOT use a subquery in an INSERT statement.

12. What is the quickest way to use today's date when you are creating a new row?
A. Simply use the keyword DATE in the insert statement.
B. Use the TODAYS_DATE function.
C. Use the SYSDATE function.
D. Simply write today's date in the format 'dd-mon-rrrr'.

13. Which of the following statements will add a new customer to the customers table in the Global
Fast Foods database?
A. INSERT INTO customers
(id 145, first_name 'Katie', last_name 'Hernandez', address '92 Chico Way', city 'Los Angeles',
state 'CA', zip 98008, phone_number 8586667641);
B. INSERT INTO customers (id, first_name, last_name, address, city, state, zip, phone_number)
VALUES ("145", 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles', 'CA', "98008",
"8586667641");
C. INSERT INTO customers (id, first_name, last_name, address, city, state, zip,
phone_number)
VALUES (145, 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles', 'CA', 98008,
8586667641);
D. INSERT IN customers (id, first_name, last_name, address, city, state, zip, phone_number);

14. The PRODUCTS table contains these columns:


PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row of data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column

You issue this statement:


INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);

What row data did you add to the table?


A. The row was created with the correct data in all three columns.
B. The row was created completely wrong. No data ended up in the correct columns.
C. The row was created with the correct data in one of the three columns.
D. The row was created with the correct data in two of three columns.

15. To return a table summary on the customers table, which of the following is correct?
A. SHOW customers, or SEE customers
B. DISTINCT customers, or DIST customers
C. DEFINE customers, or DEF customers
D. DESCRIBE customers, or DESC customers

Section 13 – DDL
1. Which statement about a column is NOT true?
A. You can modify the data type of a column if the column contains non-null data.
B. You can increase the width of a CHAR column.
C. You can convert a CHAR data type column to the VARCHAR2 data type.
D. You can convert a DATE data type column to a VARCHAR2 column.

2. Evaluate this statement:


Which statement about this TRUNCATE TABLE statement is true?
A. You can issue this statement to retain the structure of the employees table.
B. You can reverse this statement by issuing the ROLLBACK statement.
C. You can produce the same results by issuing the 'DELETE employees' statement.
D. You can produce the same results by issuing the 'DROP TABLE employee' statement.

3. Evaluate the structure of the EMPLOYEE table:


EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
Which statement should you use to increase the LAST_NAME column length to 35 if the column
currently contains 200 records?
A. ALTER TABLE employee
RENAME last_name VARCHAR2(35);
B. You CANNOT increase the width of the LAST_NAME column.
C. ALTER TABLE employee
MODIFY (last_name VARCHAR2(35));
D. ALTER employee TABLE
ALTER COLUMN (last_name VARCHAR2(35));

4. Evaluate this statement:


ALTER TABLE employees SET UNUSED (fax);

Which task will this statement accomplish?


A. Deletes the FAX column
B. Prevents a new FAX column from being added to the EMPLOYEES table
C. Prevents data in the FAX column from being displayed, by performing a logical drop of
the column
D. Frees the disk space used by the data in the FAX column

5. To completely get rid of a table, its contents, its structure, AND release the storage space the
keyword is:
A. KILL
B. TRUNCATE
C. DELETE
D. DROP

6. Evaluate this CREATE TABLE statement:


1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);

Which line of this statement will cause an error?


A. 2
B. 1
C. 3
D. 4

7. Which statement about table and column names is true?


A. Table and column names cannot include special characters.
B. Table and column names can begin with a letter or a number.
C. If any character other than letters or numbers is used in a table or column name, the name
must be enclosed in double quotation marks.
D. Table and column names must begin with a letter.

8. CREATE TABLE bioclass


(hire_date DATE DEFAULT SYSDATE,
first_name varchar2(15),
last_name varchar2(15));
The above CREATE TABLE statement is acceptable, and will create a Table named bioclass that
contains a hire_date, first_name, and last_name column. True or False?
A. benar
B. Palsu

9. When creating a new table, which of the following naming rules apply. (Choose three)
A. Must be between 1 to 30 characters long
B. Must contain ONLY A - Z, a - z, 0 - 9, _ (underscore), $, and #
C. Can have the same name as another object owned by the same user
D. Must begin with a letter
E. Must be an Oracle reserved word

10. Examine this CREATE TABLE statement:


CREATE TABLE emp_load
(employee_number CHAR(5),
employee_dob CHAR(20),
employee_last_name CHAR(20),
employee_first_name CHAR(15),
employee_middle_name CHAR(15),
employee_hire_date DATE)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY def_dir1
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS (employee_number CHAR(2),
employee_dob CHAR(20),
employee_last_name CHAR(18),
employee_first_name CHAR(11),
employee_middle_name CHAR(11),
employee_hire_date CHAR(10) date_format DATE mask "mm/dd/yyyy"))
LOCATION ('info.dat'));

What kind of table is created here?


A. An external table with the data stored in a file outside the database.
B. A View.
C. An external table with the data stored in a file inside the database.
D. None. This is in invalid statement.

11. The TIMESTAMP data type allows what?


A. Time to be stored as an interval of years and months.
B. Time to be stored as a date with fractional seconds.
C. Time to be stored as an interval of days to hours, minutes and seconds.
D. None of the above.

12. INTERVAL DAY TO SECOND stores a period of time in terms of days, hours, minutes, and
seconds. True or False?
A. benar
B. Palsu
13. The BLOB datatype can max hold 128 Terabytes of data. True or False?
A. benar
B. Palsu

14. Which of the following are valid Oracle datatypes?


A. TIMESTAMP, LOB, VARCHAR2, NUMBER
B. SYSDATE, TIMESTAMP, DATE, LOCAL TIME ZONE
C. DATE, BLOB, LOB, VARCHAR2
D. DATE, TIMESTAMP WITH LOCAL TIME ZONE, BLOB

15. Which statement about data types is true?


A. The VARCHAR2 data type should be used for fixed-length character data.
B. The CHAR data type should be defined with a size that is not too large for the data it
contains (or could contain) to save space in the database.
C. The BFILE data type stores character data up to four gigabytes in the database.
D. The TIMESTAMP data type is a character data type.

Section 14 – Constraints
1. You can drop a column in a table with a simple ALTER TABLE DROP COLUMN statement,
even if the column is referenced in a constraint. True or False?
A. benar
B. Palsu

2. The PO_DETAILS table contains these columns:


PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)

Evaluate this statement:


ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;

For which task would you issue this statement?


A. To create a new PRIMARY KEY constraint on the PO_NUM column
B. To disable the PRIMARY KEY and any FOREIGN KEY constraints that are dependent
on the PO_NUM column
C. To drop and recreate the PRIMARY KEY constraint on the PO_NUM column
D. To disable the constraint on the PO_NUM column while creating a PRIMARY KEY index

3. Evaluate this statement:


ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;

Which result will the statement provide?


A. A syntax error will be returned.
B. A constraint will be added to the EMPLOYEES table.
C. An existing constraint on the EMPLOYEES table will be enabled.
D. An existing constraint on the EMPLOYEES table will be overwritten.
4. You need to add a NOT NULL constraint to the EMAIL column in the EMPLOYEES table.
Which clause should you use?
A. DISABLE
B. CHANGE
C. MODIFY
D. ADD

5. What is the syntax for removing a PRIMARY KEY constraint and all its dependent constraints?
A. ALTER TABLE table_name
DROP CONSTRAINT constraint_name;
B. DROP CONSTRAINT table_name (constraint_name);
C. ALTER TABLE table_name
DROP CONSTRAINT constraint_name CASCADE;
D. ALTER TABLE table_name
DROP CONSTRAINT FOREIGN KEY CASCADE;

6. A composite primary key may only be defined at the table level. True or False?
A. benar
B. Palsu

7. Which of the following pieces of code will successfully create a foreign key in the CDS table that
references the SONGS table?
A. CONSTRAINT d_cd_ song_id_fk FOREIGN KEY (song_id)REFERENCES d_songs(id)
B. CONSTRAINT k_cd_songid_fk FOREIGN KEY (song_id)REFERENCES d_songs(id)
C. song_id NUMBER(5) CONSTRAINT d_cd_ song_id_fk REFERENCES d_songs(id)
D. All of the above

8. An example of adding a check constraint to limit the salary that an employee can earn is:
A. ALTER TABLE employees ADD CONSTRAINT emp_salary_ck SALARY < 100000
B. MODIFY TABLE employees ADD CONSTRAINT emp_salary_ck CHECK(salary < 100000
C. ALTER TABLE employees CONSTRAINT emp_salary_ck CHECK(salary < 100000)
D. ALTER TABLE employees ADD CONSTRAINT emp_salary_ck CHECK (salary < 100000)

9. Which constraint type enforces uniqueness?


A. NOT NULL
B. CHECK
C. FOREIGN KEY
D. PRIMARY KEY

10. Evaluate this CREATE TABLE statement:


1. CREATE TABLE part(
2. part_id NUMBER,
3. part_name VARCHAR2(25),
4. manufacturer_id NUMBER(9),
5. retail_price NUMBER(7,2) NOT NULL,
6. CONSTRAINT part_id_pk PRIMARY KEY(part_id),
7. CONSTRAINT cost_nn NOT NULL(cost),
8. CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
A. 5
B. 6
C. 7
D. 8

11. You need to ensure that each value in the SEAT_ID column is unique or null. Which constraint
should you define on the SEAT_ID column?
A. NOT NULL
B. UNIQUE
C. PRIMARY KEY
D. CHECK

12. A table can only have one unique key constraint defined. True or False?
A. benar
B. Palsu

13. A table must have at least one not null constraint and one unique constraint. True or False?
A. benar
B. Palsu

14. A table can have more than one UNIQUE key constraint. True or False?
A. benar
B. Palsu

15. Which statement about the NOT NULL constraint is true?


A. The NOT NULL constraint can be defined at either the column level or the table level.
B. The NOT NULL constraint must be defined at the column level.
C. The NOT NULL constraint prevents a column from containing alphanumeric values.
D. The NOT NULL constraint requires a column to contain alphanumeric values.

Section 15 – Views
1. A Top-N Analysis is capable of ranking a top or bottom set of results. True or False?
A. benar
B. Palsu

2. How do you remove a view?


A. DELETE VIEW view_name
B. REMOVE VIEW view_name
C. DROP VIEW view_name
D. You cannot remove a view

3. The EMPLOYEES table contains these columns:


EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that belong to
department 70?
A. SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
B. SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary" FROM
(SELECT last_name, first_name, salary, job_id FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
C. SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id, dept_id FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
D. The only way is to use the data dictionary.

4. An inline view is an unnamed select statement found:


A. Enclosed in parentheses within the select list of a surrounding query.
B. In the user_views data dictionary view.
C. In a special database column of a users table.
D. Enclosed in parentheses within the FROM clause of a surrounding query.

5. The CUSTOMER_FINANCE table contains these columns:


CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)

You created a Top-n query report that displays the account numbers and new balance of the 800
accounts that have the highest new balance value. The results are sorted by payments value from
highest to lowest.

Which SELECT statement clause is included in your query?


A. Inner query: ORDER BY new_balance DESC
B. Inner query: SELECT customer_id, new_balance ROWNUM
C. Inner query: WHERE ROWNUM = 800
D. Outer query: ORDER BY new_balance DESC

6. You administer an Oracle database. Jack manages the Sales department. He and his employees
often find it necessary to query the database to identify customers and their orders. He has asked
you to create a view that will simplify this procedure for himself and his staff. The view should
not accept INSERT, UPDATE, or DELETE operations. Which of the following statements should
you issue?
A. CREATE VIEW sales_view AS
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total FROM customers c, orders o
WHERE c.custid = o.custid);
B. CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o WHERE c.custid = o.custid)
WITH READ ONLY;
C. CREATE VIEW sales_view AS
(SELECT companyname, city, orderid, orderdate, total FROM customers, orders
WHERE custid = custid)
WITH READ ONLY;
D. CREATE VIEW sales_view AS
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;

7. You can create a view if the view subquery contains an inline view. True or False?
A. benar
B. Palsu

8. Which of the following DML operations is not allowed when using a Simple View created with
read only?
A. INSERT
B. UPDATE
C. DELETE
D. All of the above
9. You cannot insert data through a view if the view includes ______.
A. A WHERE clause
B. A column alias
C. A join
D. A GROUP BY clause

10. You need to create a new view on the EMPLOYEES table to update salary information for
employees in Department 50. You need to ensure that DML operations through the view can not
change salary values in other departments. Which clause should be included in the CREATE
VIEW statement?
A. WITH CHECK OPTION
B. OR REPLACE
C. FORCE
D. WITH READ ONLY

11. You need to create a view on the SALES table, but the SALES table has not yet been created.
Which statement is true?
A. You can create the table and the view at the same time using the FORCE option.
B. You must create the SALES table before creating the view.
C. By default, the view will be created even if the SALES table does not exist.
D. You can use the FORCE option to create the view before the SALES table has been
created.
12. Evaluate this CREATE VIEW statement:
CREATE VIEW emp_view
AS SELECT SUM(salary)
FROM employees;

Which statement is true?


A. You cannot update data in the EMPLOYEES table using the EMP_VIEW view.
B. You can update any data in the EMPLOYEES table using the EMP_VIEW view.
C. You can update only the SALARY column in the EMPLOYEES table using the EMP_VIEW
view.
D. You can delete records from the EMPLOYEES table using the EMP_VIEW view.

13. Which statement would you use to alter a view?


A. CREATE OR REPLACE VIEW
B. ALTER VIEW
C. ALTER TABLE
D. MODIFY VIEW

14. In order to query a database using a view, which of the following statements applies?
A. Use special VIEW SELECT keywords.
B. You can retrieve data from a view as you would from any table.
C. The tables you are selecting from can be empty, yet the view still returns the original data
from those tables.
D. You can never see all the rows in the table through the view.

15. A view can contain group functions. True or False?


A. benar
B. Palsu

Section 16 – Sequences and Synonyms


1. Creating a sequence with NOCACHE ensures that all numbers in the sequence's range will be
used successfully. True or False?
A. benar
B. Palsu

2. Which dictionary view would you query to display the number most recently generated by a
sequence?
A. USER_SEQUENCES
B. USER_OBJECTS
C. USER_TABLES
D. USER_CURRVALUES

3. Evaluate this statement:


CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;

Which statement about this CREATE SEQUENCE statement is true?


A. The statement fails because no INCREMENT BY value is specified.
B. The sequence will generate decrementing sequence numbers starting at 101.
C. The sequence will reuse numbers and will start with 101.
D. The sequence will generate sequence numbers starting with 101, but will not reuse numbers.

4. To see the most recent value that you fetched from a sequence named my_seq you should
reference:
A. my_seq.currval
B. my_seq.(currval)
C. my_seq.(lastval)
D. my_seq.nextval

5. What is the most common use for a Sequence?


A. To improve the performance of some queries
B. To logically represent subsets of data from one or more tables
C. To generate primary key values
D. To give an alternative name for an object

6. When creating a sequence, which keyword or option specifies the minimum sequence value?
A. CYCLE
B. MAXVALUE
C. NOMAXVALUE
D. MINVALUE

7. You created the LOCATION_ID_SEQ sequence to generate sequential values for the
LOCATION_ID column in the MANUFACTURERS table. You issue this statement:

ALTER TABLE manufacturers


MODIFY (location_id NUMBER(6));

Which statement about the LOCATION_ID_SEQ sequence is true?


A. The sequence is unchanged.
B. The sequence is deleted and must be recreated.
C. The current value of the sequence is reset to the sequence's START WITH value.
D. The current value of the sequence is reset to zero.

8. Evaluate this CREATE SEQUENCE statement:


CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;

Which statement is true?


A. The sequence will start with 1.
B. The sequence has no maximum value.
C. The sequence preallocates values and retains them in memory.
D. The sequence will continue to generate values after reaching its maximum value.

9. The CLIENTS table contains these columns:


CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of the
CLIENTS table. You execute this statement:
CREATE INDEX clients
ON address_index (city, state);

Which result does this statement accomplish?


A. An index named CLIENTS_INDEX is created on the CLIENTS table.
B. An error message is produced, and no index is created.
C. An index named CLIENTS is created on the CITY and STATE columns.
D. An index named ADDRESS_INDEX is created on the CITY and STATE columns.

10. For which column would you create an index?


A. The column contains a wide range of values
B. A column that is infrequently used as a query search condition
C. A column that is updated frequently
D. A column which has only 4 distinct values.

11. What kind of INDEX is created by Oracle when you create a primary key?
A. UNIQUE INDEX
B. NONUNIQUE INDEX
C. INDEX
D. Oracle cannot create indexes automatically.

12. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME column. You want to
change this index so that it is on the FIRST_NAME column instead. Which SQL statement will
do this?
A. ALTER INDEX ln_idx ON employees(first_name);
B. ALTER INDEX ln_idx TO employees(first_name);
C. ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
D. None of the above; you cannot ALTER an index.

13. User Mary's schema contains an EMP table. Mary has Database Administrator privileges and
executes the following statement:

CREATE PUBLIC SYNONYM emp FOR mary.emp;

User Susan now needs to SELECT from Mary's EMP table. Which of the following SQL
statements can she use? (Choose two)

A. CREATE SYNONYM marys_emp FOR mary(emp);


B. SELECT * FROM emp.mary;
C. SELECT * FROM emp;
D. SELECT * FROM mary.emp;

14. Which of the following best describes the function of an index?


A. An index can prevent users from viewing certain data in a table.
B. An index can run statement blocks when DML actions occur against a table.
C. An index can reduce the time required to grant multiple privileges to users.
D. An index can increase the performance of SQL queries that search large tables.

15. All tables must have indexes on them otherwise they cannot be queried. True or False?
A. benar
B. Palsu
Section 17 - Privileges and Regular Expressions
1. Which of the following simplifies the administration of privileges?
A. A role
B. An index
C. A trigger
D. A view

2. When granting an object privilege, which option would you include to allow the grantee to grant
the privilege to another user?
A. PUBLIC
B. WITH GRANT OPTION
C. WITH ADMIN OPTION
D. FORCE

3. To join a table in your database to a table on a second (remote) Oracle database, you need to use:
A. An Oracle gateway product
B. A database link
C. An ODBC driver
D. A remote procedure call

4. A role can be granted to another role. True or False?


A. benar
B. Palsu

5. Which statement would you use to add privileges to a role?


A. GRANT
B. CREATE ROLE
C. ALTER ROLE
D. ASSIGN

6. You need to grant user BOB SELECT privileges on the EMPLOYEES table. You want to allow
BOB to grant this privileges to other users. Which statement should you use?
A. GRANT SELECT ON employees TO bob WITH GRANT OPTION;
B. GRANT SELECT ON employees TO bob;
C. GRANT SELECT ON employees TO PUBLIC WITH GRANT OPTION;
D. GRANT SELECT ON employees TO bob WITH ADMIN OPTION;

7. Regular expressions used as check constraints are another way to ensure data is formatted
correctly prior to being written into the database table. True or False?
A. True
B. False

8. REGULAR EXPRESSIONS can be used on CHAR, CLOB, and VARCHAR2 datatypes? (True or
False)
A. benar
B. Palsu
9. Parentheses are not used to identify the sub expressions within the expression. True or False?
A. True
B. False
10. User ADAM has successfully logged on to the database in the past, but today he receives an error
message stating that (although he has entered his password correctly) he cannot log on. What is
the most likely cause of the problem?
A. ADAM's CREATE SESSION privilege has been revoked.
B. ADAM's CREATE USER privilege has been revoked.
C. ADAM's user account has been removed from the database.
D. One or more object privileges have been REVOKEd from Adam.

11. Which of the following best describes a role in an Oracle database?


A. A role is the part that a user plays in querying the database.
B. A role is a name for a group of privileges.
C. A role is a type of system privilege.
D. A role is an object privilege which allows a user to update a table.

12. The database administrator wants to allow user Marco to create new tables in his own schema.
Which privilege should be granted to Marco?
A. CREATE ANY TABLE
B. CREATE TABLE
C. SELECT
D. CREATE OBJECT

13. A schema is:


A. Required to manipulate the content of objects in the database.
B. A named group of related privileges given to a user.
C. A collection of objects, such as tables, views, and sequences.
D. Required to gain access to the database.

14. You want to grant user BOB the ability to change other users' passwords. Which privilege should
you grant to BOB?
A. The CREATE PROFILE privilege
B. The DROP USER privilege
C. The ALTER USER privilege
D. The CREATE USER privilege

15. The following table shows some of the output from one of the data dictionary views. Which view
is being queried?
USERNAME PRIVILEGE ADMIN_OPTION
USCA_ORACLE_SQL01_S08 CREATE VIEW NO
USCA_ORACLE_SQL01_S08 CREATE TABLE NO
USCA_ORACLE_SQL01_S08 CREATE SYNONYM NO
USCA_ORACLE_SQL01_S08 CREATE TRIGGER NO
USCA_ORACLE_SQL01_S08 CREATE SEQUENCE NO
USCA_ORACLE_SQL01_S08 CREATE DATABASE NO
A. role_sys_privs (lists system privileges granted to roles)
B. user_tab_privs_recd (lists object privileges granted to the user)
C. role_tab_privs (lists table privileges granted to roles)
D. user_sys_privs (lists system privileges granted to the user)
Section 18 – TCL
1. Which of the following best describes the term "read consistency"?
A. It prevents other users from seeing changes to a table until those changes have been
committed
B. It ensures that all changes to a table are automatically committed
C. It prevents users from querying tables on which they have not been granted SELECT
privilege
D. It prevents other users from querying a table while updates are being executed on it

2. COMMIT saves all outstanding data changes? True or False?


A. benar
B. Palsu

3. Table MYTAB contains only one column of datatype CHAR(1). A user executes the following
statements in the order shown.
INSERT INTO mytab VALUES ('A');
INSERT INTO mytab VALUES ('B');
COMMIT;
INSERT INTO mytab VALUES ('C');
ROLLBACK;

Which rows does the table now contain?


A. A, B, and C
B. A and B
C. C
D. None of the above

4. User BOB's CUSTOMERS table contains 20 rows. BOB inserts two more rows into the table but
does not COMMIT his changes. User JANE now executes:

SELECT COUNT(*) FROM bob.customers;

What result will JANE see?


A. 2
B. 20
C. 22
D. JANE will receive an error message because she is not allowed to query the table while BOB
is updating it.

5. Examine the following statements:


INSERT INTO emps SELECT * FROM employees; -- 107 rows inserted.
SAVEPOINT Ins_Done;
CREATE INDEX emp_lname_idx ON employees(last_name);
UPDATE emps SET last_name = 'Smith';

What happens if you issue a Rollback statement?


A. The update of last_name is undone, but the insert was committed by the CREATE
INDEX statement.
B. Both the UPDATE and the INSERT will be rolled back.
C. The INSERT is undone but the UPDATE is committed.
D. Nothing happens.

6. You need not worry about controlling your transactions. Oracle does it all for you. True or False?

A, benar
C. Palsu

7. Steven King's row in the EMPLOYEES table has EMPLOYEE_ID = 100 and SALARY = 24000.
A user issues the following statements in the order shown:
UPDATE employees
SET salary = salary * 2
WHERE employee_id = 100;
COMMIT;

UPDATE employees
SET salary = 30000
WHERE employee_id = 100;

The user's database session now ends abnormally. What is now King's salary in the table?
A. 24000
B. 78000
C. 48000
D. 30000

8. Which SQL statement is used to remove all the changes made by an uncommitted transaction?
A. ROLLBACK TO SAVEPOINT;
B. REVOKE;
C. ROLLBACK;
D. UNDO;

9. If Oracle crashes, your changes are automatically rolled back. True or False?
A. benar
B. Palsu

10. When you logout of Oracle, your data changes are automatically rolled back. True or False?
A. benar
B. Palsu

11. Examine the following statements:


UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;

You want to retain all the employees with a salary of 15000; What statement would you execute
next?
A. ROLLBACK;
B. ROLLBACK TO SAVEPOINT upd1_done;
C. ROLLBACK TO SAVEPOINT upd2_done;
D. ROLLBACK TO SAVE upd1_done;
E. There is nothing you can do; either all changes must be rolled back, or none of them can be
rolled back.

12. A transaction makes several successive changes to a table. If required, you want to be able to
rollback the later changes while keeping the earlier changes. What must you include in your code
to do this?
A. An object privilege
B. An update statement
C. A sequence
D. A database link
E. A savepoint

13. Examine the following statements:


INSERT INTO emps SELECT * FROM employees; -- 107 rows inserted.
SAVEPOINT Ins_Done;
DELETE employees; -- 107 rows deleted
SAVEPOINT Del_Done;
UPDATE emps SET last_name = 'Smith';

How would you undo the last Update only?


A. There is nothing you can do.
B. ROLLBACK UPDATE;
C. ROLLBACK to SAVEPOINT Del_Done;
D. COMMIT Del_Done;

14. If a database crashes, all uncommitted changes are automatically rolled back. True or False?
A. benar
B. Palsu

15. If UserB has privileges to see the data in a table, as soon as UserA has entered data into that table,
UserB can see that data. True or False?
A. benar
B. Palsu

Section 19 - Final Project and Exam Review


Section 20 - Ensuring Quality Queries Part II
Database Programming with SQL Final Exam
Section 12
1. A column in a table can be given a default value. This option prevents NULL values from
automatically being assigned to the column if a row is inserted without a specified value for the
column. True or False ?
A. True
B. False
2. A multi-table insert statement can insert into more than one table. (True or False?)
A. benar
B. Palsu

3. If the employees table has 7 rows, how many rows are inserted into the copy_emps table with the
following statement:

INSERT INTO copy_emps (employee_id, first_name, last_name, salary, department_id)


SELECT employee_id, first_name, last_name, salary, department_id
FROM employees
A. No rows, as you cannot use subqueries in an insert statement.
B. 7 rows, as no WHERE-clause restricts the rows returned on the subquery.
C. No rows, as the SELECT statement is invalid.
D. 10 rows will be created.

4. When inserting a new row, the null keyword can be included in the values list for any column that
allows nulls. True or False?
A. benar
B. Palsu

5. You need to update the expiration date, but only for products manufactured before June 30th . In
which clause of the UPDATE statement will you specify this condition?
A. The SET clause
B. The WHERE clause
C. The ON clause
D. The USING clause

6. Which of the following represents the correct syntax for an INSERT statement?
A. INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
B. INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN'
'37777';
C. INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN',
'37777');
D. INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;

7. What would happen if you issued a DELETE statement without a WHERE clause?
A. An error message would be returned.
B. Only one row would be deleted.
C. All the rows in the table would be deleted.
D. No rows would be deleted.

8. The PLAYERS table contains these columns:


PLAYER_ID NUMBER NOT NULL
PLAYER_LNAME VARCHAR2(20) NOT NULL
PLAYER_FNAME VARCHAR2(10) NOT NULL
TEAM_ID NUMBER
SALARY NUMBER(9,2)

You need to increase the salary of each player for all players on the Tiger team by 12.5 percent.
The TEAM_ID value for the Tiger team is 5960. Which statement should you use?
A. UPDATE players (salary)
SET salary = salary * 1.125;
B. UPDATE players
SET salary = salary * .125
WHERE team_id = 5960;
C. UPDATE players
SET salary = salary * 1.125
WHERE team_id = 5960;
D. UPDATE players (salary)
VALUES(salary * 1.125)
WHERE team_id = 5960;

Section 13
9. To completely get rid of a table, its contents, its structure, AND release the storage space the
keyword is:
A. KILL
B. DELETE
C. DROP
D. TRUNCATE

10. Evaluate this statement:


ALTER TABLE employees SET UNUSED (fax);

Which task will this statement accomplish?


A. Prevents a new FAX column from being added to the EMPLOYEES table
B. Prevents data in the FAX column from being displayed, by performing a logical drop of the C.
column
C. Frees the disk space used by the data in the FAX column
D. Deletes the FAX column

11. Evaluate the structure of the EMPLOYEE table:


EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)

Which statement should you use to increase the LAST_NAME column length to 35 if the column
currently contains 200 records?
A. ALTER TABLE employee
RENAME last_name VARCHAR2(35);
B. You CANNOT increase the width of the LAST_NAME column.
C. ALTER TABLE employee
MODIFY (last_name VARCHAR2(35));
D. ALTER employee TABLE
ALTER COLUMN (last_name VARCHAR2(35));

12. Which command could you use to quickly remove all data from the rows in a table without
deleting the table itself?
A. MODIFY
B. ALTER TABLE
C. TRUNCATE TABLE
D. DROP TABLE

13. Comments can be added to a table by using the COMMENT ON TABLE statement. The
comments being added are enclosed in:
A. Brackets { }
B. Single quotes ' '
C. Double quotes " "
D. Parentheses ( )

14. The previous administrator created a table named CONTACTS, which contains outdated data.
You want to remove the table and its data from the database. Which statement should you issue?
A. TRUNCATE TABLE
B. DROP TABLE
C. ALTER TABLE
D. DELETE

15. Evaluate this CREATE TABLE statement:


CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));

Which business requirement will this statement accomplish?


A. All employee identification values are only 6 digits so the column should be variable in
length.
B. Description values can range from 0 to 30 characters so the column should be fixed in length.
C. Today's date should be used if no value is provided for the sale date.
D. Sales identification values could be either numbers or characters, or a combination of both.

16. The SPEED_TIME column should store a fractional second value.


Which data type should you use?
A. INTERVAL DAY TO SECOND
B. TIMESTAMP
C. DATE
D. DATETIME

17. Given this employee table:


(employee_id NUMBER(10) NOT NULL,
first_name VARCHAR2(25) NOT NULL,
last_name VARCHAR2(30) NOT NULL,
hire_date DATE DEFAULT sysdate)

What will be the result in the hire_date column following this insert statement:
INSERT INTO employees VALUES (10, 'Natacha', 'Hansen', DEFAULT);
A. The column for hire_date will be null.
B. The character string SYSDATE.
C. Statement will work and the hire_date column will have the value of the date when the
statement was run.
D. Statement will fail, as you must list the columns into which you are inserting.

18. CREATE TABLE bioclass


(hire_date DATE DEFAULT SYSDATE,
first_name varchar2(15),
last_name varchar2(15));

The above CREATE TABLE statement is acceptable, and will create a Table named bioclass that
contains a hire_date, first_name, and last_name column. True or False?
A. benar
B. Palsu

19. It is possible to create a table by using the CREATE TABLE command in conjunction with a
subquery. True or False?
A. benar
B. Palsu

Section 14
20. Which two statements about NOT NULL constraints are true? (Choose two)
A. Columns with a NOT NULL constraint can contain null values by default.
B. A NOT NULL constraint can be defined at either the table or column level.
C. The Oracle Server creates a name for an unnamed NOT NULL constraint.
D. The NOT NULL constraint requires that every value in a column be unique.
E. You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
ADD CONSTRAINT statement.

21. A column defined as NOT NULL can have a DEFAULT value of NULL. True or False?
A. benar
B. Palsu

22. Which statement about the NOT NULL constraint is true?


A. The NOT NULL constraint can be defined at either the column level or the table level.
B. The NOT NULL constraint prevents a column from containing alphanumeric values.
C. The NOT NULL constraint must be defined at the column level.
D. The NOT NULL constraint requires a column to contain alphanumeric values.

23. When creating the EMPLOYEES table, which clause could you use to ensure that salary values
are 1000.00 or more?
A. CHECK CONSTRAINT (salary > 1000)
B. CHECK CONSTRAINT employee_salary_min (salary > 1000)
C. CONSTRAINT employee_salary_min CHECK salary > 1000
D. CONSTRAINT CHECK salary > 1000
E. CONSTRAINT employee_salary_min CHECK (salary >= 1000)
24. Which constraint type enforces uniqueness?
A. PRIMARY KEY
B. NOT NULL
C. FOREIGN KEY
D. CHECK

25. You disabled the EMPLOYEE_ID_PK PRIMARY KEY constraint on the ID column in the
EMPLOYEES table and imported 100 records. You need to enable the constraint and verify that
the new and existing ID column values do not violate the PRIMARY KEY constraint. Evaluate
this statement:

ALTER TABLE employees


ENABLE employee_id_pk;

Which statement is true?


A. The statement will achieve the desired result.
B. The statement will NOT execute because it contains a syntax error.
C. The statement will execute, but will ensure that the new ID values are unique.
D. The statement will execute, but will not verify that the existing values are unique.

26. The LINE_ITEM table contains these columns:


LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)

You need to disable the FOREIGN KEY constraint. Which statement should you use?
A. ALTER TABLE line_item
DROP CONSTRAINT product_id_fk;
B. ALTER TABLE line_item
DELETE CONSTRAINT product_id_fk;
C. ALTER TABLE line_item
ENABLE CONSTRAINT product_id_fk;
D. ALTER TABLE line_item
DISABLE CONSTRAINT product_id_fk;

Section 15
27. For a View created using the WITH CHECK OPTION keywords, which of the following
statements are true?
A. The view will allow the user to check it against the data dictionary
B. Prohibits changing rows not returned by the subquery in the view definition.
C. Prohibits DML actions without administrator CHECK approval
D. Allows for DELETES from other tables, including ones not listed in subquery

28. Examine the view below and choose the operation that CANNOT be performed on it.
CREATE VIEW dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT(e.name)
FROM d_clients c, d_events e
WHERE c.client_number = e.client_number
GROUP BY c.last_name

A. SELECT last_name, number_events FROM dj_view;


B. DROP VIEW dj_view;
C. CREATE OR REPLACE dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT (e.name)
FROM d_clients c, d_events e
WHERE c.client_number=e.client_number
GROUP BY c.last_name;
D. INSERT INTO dj_view VALUES ('Turner', 8);

29. Which statement about performing DML operations on a view is true?


A. You cannot modify data in a view if the view contains a group function.
B. You cannot modify data in a view if the view contains a WHERE clause.
C. You can modify data in a view if the view contains a GROUP BY clause.
D. You can delete data in a view if the view contains the DISTINCT keyword.

30. An inline view is an unnamed select statement found:


A. In the user_views data dictionary view.
B. In a special database column of a users table.
C. Enclosed in parentheses within the FROM clause of a surrounding query.
D. Enclosed in parentheses within the select list of a surrounding query.

31. How do you remove a view?


A. DELETE VIEW view_name
B. REMOVE VIEW view_name
C. DROP VIEW view_name
D. You cannot remove a view

32. Unlike tables, views contain no data of their own. True or False?
A. benar
B. Palsu

33. In order to query a database using a view, which of the following statements applies?
A. Use special VIEW SELECT keywords.
B. You can never see all the rows in the table through the view.
C. You can retrieve data from a view as you would from any table.
D. The tables you are selecting from can be empty, yet the view still returns the original data
from those tables.

34. You administer an Oracle database which contains a table named EMPLOYEES. Luke, a database
user, must create a report that includes the names and addresses of all employees. You do not want
to grant Luke access to the EMPLOYEES table because it contains sensitive data. Which of the
following actions should you perform first?
A. Create a report for him.
B. Create an index.
C. Create a subquery.
D. Create a view.
Section 16
35. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;

Which statement is true?


A. The statement will not execute successfully.
B. The sequence will generate sequential descending values.
C. The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible integer value.
D. The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.

36. When used in a CREATE SEQUENCE statement, which keyword specifies that a range of
sequence values will be preloaded into memory?
A. NOCYCLE
B. MEMORY
C. NOCACHE
D. LOAD
E. CACHE

37. Which statement would you use to remove the EMP_ID_SEQ sequence?
A. ALTER SEQUENCE emp_id_seq;
B. DELETE SEQUENCE emp_id_seq;
C. REMOVE SEQUENCE emp_id_seq;
D. DROP SEQUENCE emp_id_seq;

38. The following indexes exist on the EMPLOYEES table:


 A unique index on the EMPLOYEE_ID primary key column
 A non-unique index on the JOB_ID column
 A composite index on the FIRST_NAME and LAST_NAME columns.

If the EMPLOYEES table is dropped, which indexes are automatically dropped at the same time?
A. EMP_ID only
B. JOB_ID only
C. DEPT_ID only
D. EMP_ID and JOB_ID
E. All Indexes

39. Barry creates a table named INVENTORY. Pam must be able to query the same table. Barry
wants to enable Pam to query the table without being required to specify the table's schema.
Which of the following should Barry create?
A. An index
B. A synonym
C. A schema
D. A view

40. Which of the following SQL statements will display the index name, table name, and the
uniqueness of the index for all indexes on the EMPLOYEES table?
A. SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
B. SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
C. SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
D. CREATE index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';

Section 17
41. The following table shows some of the output from one of the data dictionary views. Which view
is being queried?
USERNAME PRIVILEGE ADMIN_OPTION
USCA_ORACLE_SQL01_S08 CREATE VIEW NO
USCA_ORACLE_SQL01_S08 CREATE TABLE NO
USCA_ORACLE_SQL01_S08 CREATE SYNONYM NO
USCA_ORACLE_SQL01_S08 CREATE TRIGGER NO
USCA_ORACLE_SQL01_S08 CREATE SEQUENCE NO
USCA_ORACLE_SQL01_S08 CREATE DATABASE NO

A. role_tab_privs (lists table privileges granted to roles)


B. user_sys_privs (lists system privileges granted to the user)
C. user_tab_privs_recd (lists object privileges granted to the user)
D. role_sys_privs (lists system privileges granted to roles)

42. Which of the following privileges must be assigned to a user account in order for that user to
connect to an Oracle database?
A. CREATE SESSION
B. ALTER SESSION
C. RESTRICTED SESSION
D. OPEN SESSION

43. REGULAR EXPRESSIONS does exactly the same as LIKE--no more and no less. (True or
False?)
A. benar
B. Palsu

44. REGULAR EXPRESSIONS can be used on CHAR, CLOB, and VARCHAR2 datatypes? (True or
False)
A. benar
B. Palsu

45. To take away a privilege from a user, you use which command?
A. ALTER
B. REMOVE
C. REVOKE
D. DELETE
46. What Oracle feature simplifies the process of granting and revoking privileges?
A. Role
B. Data dictionary
C. Object
D. Schema

47. Which keyword would you use to grant an object privilege to all database users?
A. ADMIN
B. ALL
C. PUBLIC
D. USERS

Section 18
48. COMMIT saves all outstanding data changes? True or False?
A. benar
B. Palsu

49. Examine the following statements:


UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;

You want to retain all the employees with a salary of 15000; What statement would you execute
next?
A. ROLLBACK;
B. ROLLBACK TO SAVEPOINT upd1_done;
C. ROLLBACK TO SAVEPOINT upd2_done;
D. ROLLBACK TO SAVE upd1_done;
E. There is nothing you can do; either all changes must be rolled back, or none of them can be
rolled back.

50. Testing is done by programmers. True or False?


A. benar
B. Palsu

You might also like