Book Image

OCA Oracle Database 11g: SQL Fundamentals I: A Real World Certification Guide ( 1ZO-051 )

By : Steve Ries
Book Image

OCA Oracle Database 11g: SQL Fundamentals I: A Real World Certification Guide ( 1ZO-051 )

By: Steve Ries

Overview of this book

<p>The Oracle Database 11g: SQL Fundamentals I exam is the first stepping stone in getting the Oracle Certified Associate Certification for Oracle Database 11g. The SQL programming language is used in every major relational database today and understanding the real world application of it is the key to becoming a successful DBA.<br /><br />This book gives you: the essential real world skills to master relational data manipulation with Oracle SQL and prepares you to become an Oracle Certified Associate. Beginners are introduced to concepts in a logical manner while practitioners can use it as a reference to jump to relevant concepts directly.<br /><br />We begin with the essentials of why databases are important in today's information technology world and how they work.<br /><br />We continue by explaining the concepts of querying and modifying data in Oracle using a range of techniques, including data projection, selection, creation, joins, sub-queries and functions. Finally, we learn to create and manipulate database objects and to use them in the same way as today's expert SQL programmers.<br /><br />This book prepares you to master the fundamentals of the SQL programming language using an example-driven method that is easy to understand<br /><br />This definitive certification guide provides a disciplined approach to be adopted for successfully clearing the 1Z0-051 SQL Fundamentals I exam, which is the first stepping stone towards attaining the OCA on Oracle Database 11g certification.<br /><br />Each chapter contains ample practice questions at the end. A full-blown mock test is included for practice so you can test your knowledge and get a feel for the actual exam.</p>
Table of Contents (20 chapters)
OCA Oracle Database 11g: SQL Fundamentals I: A Real-World Certification Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with SQL


'Often, the best way to learn something is hands-on. To best facilitate this, we will use a scaled-down set of data that mirrors the type of data used in the real world.

Introducing the Companylink database

This book focuses on two objectives:

  1. To prepare you for the 11g SQL Fundamentals I exam (Oracle exam #1Z0-051).

  2. To present the knowledge needed for the exam in such a way that you can use it in a real-world setting.

To that end, rather than using the default tables included in Oracle, we will be working with simulated real-world data. The database we will use throughout this book is for the fictional company, Companylink. Although most people are aware of the impact of social networking in our private lives, companies are realizing the importance of using it in their industries as well. Companylink is a business that focuses on social networking in the corporate setting. The data model that we will use is a small but realistic set of working data that could support a social networking website. The following tables are included in the Companylink database, which can be downloaded from Packt support site as well as comments about the business rules that constrain them:

  • Employee: Information about employees that use the Companylink site.

  • Address: The street address information.

  • Branch: The corporate branch to which each employee belongs. Each employee belongs to one branch.

  • Division: It is the corporate division to which each branch belongs. Each division is associated with multiple branches.

  • E-mail: An employee can store multiple e-mail addresses.

  • Message: Our fictional Companylink social networking site allows you to send messages to fellow employees. That information is stored here.

  • Website: Companylink allows users to create their own personal web pages. The URL of these pages is contained in this table.

  • Blog: In addition to a website, users can optionally create their own blogs. This information is stored in the Blog table.

  • Project: Each employee is assigned to a single primary project, which is contained here.

  • Award: Employees can win corporate awards. The list of possible awards is stored here. Employees can win more than one award.

  • Employee_award: This table is used to relate employees with their awards. Since multiple employees can win the same award and multiple awards can be won by the same employee, this creates a many-to-many table relationship, which, in the relational paradigm, must be avoided. The employee_award table divides this many-to-many relationship into two distinct one-to-many relationships.

To create our database, we need to run the downloaded Windows command file. Simply unzip the companylink.zip file into a directory and double-click on the companylink_db.cmd file. The execution of the file will do the following:

  • Make a connection to the database

  • Create a user called companylink with the password companylink

  • Create the tables used for the examples in this book

  • Populate these tables with data

  • Output two log files: companylink_ddl.txt and companylink_data.txt

If you wish, the log files can be used to verify successful execution of the script. The command file is completely reusable, which is to say that if you break any of the tables or data, you only need to disconnect from the database and double-click the command file again. It will drop the existing data and rebuild the tables from scratch. When you do this, keep in mind that any data you add yourself will be deleted as well. Throughout the book, we will continually be writing SQL statements that access these tables and will even add new ones.

The creation of these tables requires a working installation of the Oracle database software on a machine to which you have access. Fortunately, the Oracle software can be downloaded from http://www.oracle.com/technology. There is no purchased license required if you use the software for your own learning purposes.

Tip

SQL in the real world

When you're starting out with SQL and Oracle, it's important to get hands-on. Although Oracle makes its software available at no charge for personal use, many aspiring DBAs are hesitant to install it on their personal computers. By using free desktop virtualization software, such as Virtualbox, you can create a virtual machine on your home computer that can be used as your self-contained database server. Whenever you want to work with Oracle, simply start your virtual machine. Whenever you finish, shutdown the virtual machine, and all the resources it used will be released. Virtualization can be a useful solution to isolate your Oracle work from your home use without buying another computer.