Getting Started

Before diving into the code, review the tables you'll work with throughout this chapter. The better part of this chapter deals with the three tables from Chapter 2. If you aren't familiar with them, don't worry; you'll take another quick look at the entity relationship diagram (ERD). If you don't need a refresher, skip ahead to the "Installing PDO" section later in this chapter. If you haven't read Chapter 2 and want to use the code directly, refer to the Data Definition Language (DDL) _the SQL statements defining the data structures_in that chapter to construct the database on your system.

The application contains three tables, as shown in Figure 5-1. The accounts table contains all the accounts in the system. User details are stored here: e-mail, password, username, and so on.

The accounts_artists join table allows users to identify themselves as fans of one or more artists stored in the artists table. Using the ID of the user stored in the accounts table along with the ID of the artist stored in the artists table, you can associate an account with an artist and store the date when the user became a fan of the artist.

The artists table contains a list of artists in the system. Users enter each of the artists in this table, which cannot have any duplicates, and an artist can belong to only one genre. The table contains the artist name, genre, date the record was created, and unique ID of the record.

accounts

*PK id: INTEGER

* username: VARCHAR(20)

* email: VARCHAR(200)

* password: VARCHAR(20)

* status: VARCHAR(10) = pending

* email_newsletter_status: VARCHAR(3) = out

* emailjype: VARCHAR(4) = text

* email_favorite_artists_status: VARCHAR(3) = out

* created_date: DATETIME

<<unique>> + UQ_Accounts_email() + UQ_Accounds_id() + UQ_Accounts_username()

<<unique>> + UQ_Accounts_email() + UQ_Accounds_id() + UQ_Accounts_username()

accountsartists

* account_id: INTEGER

* artistjd: INTEGER

* created_date: DATETIME rating: INTEGER is_fav: INTEGER

+ PK_Accounts_Artists(INTEGER) <<unique>>

+ UQ_Accounts_Artists_id()

artists

* artist_name: VARCHAR(200)

* genre: VARCHAR(100)

* created_date: DATETIME

* artist_name: VARCHAR(200)

* genre: VARCHAR(100)

* created_date: DATETIME

Figure 5-1. LoudBite database ERD

You now have an overall understanding of the database that powers the next couple of examples. Let's head over to the next section and get to work.

Was this article helpful?

0 0

Post a comment