Chapter 2. The Task Time Tracker Database

This chapter defines the Task Time Tracker (3T) database design and configures NetBeans as a client of MySQL server.

The 3T application will be used to keep track of the time spent on different tasks for different company projects. The main entities are:

  • Company: This is the entity that owns zero or more projects. A company is independent and can exist in its own right (it has no foreign keys).
  • Project: This represents a grouping of tasks. Each project belongs to exactly one company and may contain zero or more tasks.
  • Tasks: These represent activities that may be undertaken for a project. A task belongs to exactly one project.
  • Users: They are participants who undertake tasks. Users can assign time spent to different tasks.
  • Task log: This is a record of the time spent by a user on a task. The time spent is stored in minutes.

These entity definitions result in a very simple database design:

The Task Time Tracker Database

We will prefix all of our 3T tables with ttt_. Large enterprise databases may contain hundreds of tables, and you will soon appreciate the prefixing of table names to group related tables.

Connecting NetBeans with MySQL

Click on the Services tab in the NetBeans IDE, and navigate to Databases | Drivers. You will see that NetBeans comes with several different database drivers:

Connecting NetBeans with MySQL

Right-click on the Databases node, and click on Register MySQL Server…as shown in the following screenshot:

Connecting NetBeans with MySQL

For Windows users, this will open a dialog box with default settings. Enter the admin password used when installing MySQL server in the previous chapter, and check the Remember Password option:

Connecting NetBeans with MySQL

Mac users will see a different window prior to setting the connection properties. Select the MySQL driver before clicking on the Next button:

Connecting NetBeans with MySQL

This will then allow you to specify the required database connection details:

Connecting NetBeans with MySQL

When finished with these tasks, you will see MySQL Server listed in the Databases node. Right-click on the server, and select Connect to connect to the server (if not already connected):

Connecting NetBeans with MySQL

This will connect NetBeans to MySQL server and list the available databases. Right-click on the server, and select Create Database as shown in the following screenshot:

Connecting NetBeans with MySQL

Enter the database name as shown in the following screenshot, and click on OK to create the database:

Connecting NetBeans with MySQL

The final step is to connect to the newly created task_time_tracker database. Right-click on task_time_tracker and select Connect… as shown in the following screenshot:

Connecting NetBeans with MySQL

This will add a MySQL database connection entry for the task_time_tracker database, which can be opened by right-clicking on it whenever required:

Connecting NetBeans with MySQL

Now you can right-click on the database connection and select the Execute Command… option to open the SQL Command editor in the workspace:

Connecting NetBeans with MySQL

The SQL Command editor is where you will type and execute commands against the database:

Connecting NetBeans with MySQL
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.47.166