Initializing the Tables for Products and Departments


Initializing Some Tables.  You should have one overall directory for your webstore called firefox.  It should have the following subdirectories/folders.
  • firefox
    • images
    • images_dept
    • images_prod
    • includes
    • store_manager

The following table displays the images you need to copy into the images_dept folder.



Image Name


The following table displays the entries that should be placed in the department table.


id_department department_name department_descritpion department_image
1 Edible Panties Don't get your panties in a bunch, munch them for brunch or lunch dept_edibles.jpg
2 Amerindian DVDs Some artistic efforts from the far too silent minority. dept_native_dvds.jpg
3 Kurosawa DVDs A Japanese master of movie making. dept_kurosawa.jpg
4 Martial Arts DVDs Some say it should be long rather than dragon.  Enter some real efforts to portray longs. dept_martial_arts.jpg
5 T Shirts We carry t-shirts with a passion. dept_tshirts.gif


So that you can see how to initialize the entries in this table I will lead you through the steps using the MySQL Admin on your account at  You can then follow these same steps to initialize the other tables we are about to delineate later in this webpage.

First you need to get back into the MySQL Admin and access your database.  After following the usual steps you should see a page like the following.



If you click on the insert icon/button in the department row you should get a page containing the following.



At which point you should enter the information about the Edible Panties department.  Remember you can copy the words into the appropriate field.  You also shouldn't enter any id_department so that it will auto increment.  Then you should press the Go button to insert the record.

You also need to do this for the other four departments.

Once you have done this you can press the browse icon associated with the department table to see the following segment of your screen.



This lets you know they've been initialized.

If you need to correct anything you can press the edit button/icon for that particular record.  This button/icon looks like a pencil.

Product Initialization.  The following table displays a set of images you need to copy into the images_prod folder.  This first set of images will appear on the departments page and all have sm_ at the beginning of their names.  These images are smaller because more than one will appear on each department's page.


Image Name


The following table displays another set of images you need to copy into the images_prod folder.  This second set of images will appear on the page for each product.


Image Name


The following table displays the initializations for the products table.  While the weights are in lbs, you should only enter the number.  In order for our website to work you need to enter this information.

Fortunately, we will eventually develop the store manager interface that will greatly improve modifying these tables and the rest in the firefox database.


id_product product_name product_description product_image weight
1 Womens Edible Panties These crotchless panties will leave your mate always asking for more. prod_female_edibles.gif 1.6 7.49
2 Mens Edible Undies These edible undies will definitely liven up your meal time. prod_male_edibles.gif 2.0 7.49
3 Dreamkeeper DVD A miniseries based on current native themes and action. prod_dreamkeeper.jpg 4.5 39.95
4 Powwow Highway DVD Native wanderlust finding its way across the highways of the US following a trail of native powwows. prod_powwow_highway.jpg 1.4 19.95
5 Rashomon DVD   prod_rashomon.jpg 1.3 24.95
6 The Seven Samurai DVD A dramatic comedy about a band of samurai defending Japanese farmers from a large extortionist gang. prod_seven_samurai.jpg 1.3 24.95
7 Crouching Tiger Hidden Dragon DVD Oriental mysticism bonds with martial arts and love to create an epic journey. prod_crouching_tiger.jpg 1.5 19.95
8 Iron Monkey DVD A warrior/healer defends his region against corrupt officialdom. prod_iron_monkey.jpg 1.4 19.95
9 The Last Dragon DVD A black American youth develops his spirit and whole body glow in his quest for dealing everything justly. prod_last_dragon.jpg 1.4 19.95
10 Eagle Feather T-Shirt A t-shirt depicting an eagle guardian spirit giving a feather to a questing youth. prod_eagle_feather.gif 2.3 21.95
11 The Sentinels T-Shirt A t-shirt depicting a cougar guardian spirit protecting a youth in his duties. prod_the_sentinels.gif 2.3 21.95


Relating Products to Departments.  We have chosen to use a configuration that makes use of a separate table to relate products and departments.  This approach is actually more flexible than just having an extra field in the products table that tells which department it is in.  This way it is possible to list products in more than one department and it is possible to use this same sort of approach to relate different products to each other.  For example, if we were selling camera equipment, you might want to make sure certain flashes and lenses are associated with particular cameras.

But, while this table might appear quite abstract at first, it really serves a purpose.  The table we are about display the initializations for is called department_products.  It is still best to have a key, even though these numbers are really quite arbitrary and basically just enumerating how many department product relationships we have,

You will need to initialize the following table.


id_department_product id_department id_product
1 1 1
2 1 2
3 2 3
4 2 4
5 3 5
6 3 6
7 4 7
8 4 8
9 4 9
10 5 10
11 5 11


Attributes.  In an earlier webpage we talked about coordinating/assigning products with their attributes.  Remember, within our products we have just two that have attributes.
  • edible panties
    • flavor
      • apple
      • cherry
      • strawberry
      • watermelon
    • size
      • small
      • medium
      • large
      • extra large
  • t shirts
    • size
      • small
      • medium
      • large
      • extra large


But it is key to remember that we have designed our tables so that we can easily add more products using these or other attributes.

First we need a table that defines our attribute categories called attribute_category.  The initializations follow.



id_attribute_category category_name
1 flavor
2 size


Now we need to define the specific attributes our products can have and sort them into their categories.  This is done in a table called attribute.


id_attribute attribute_name id_attribute_category
1 apple 1
2 cherry 1
3 strawberry 1
4 watermelon 1
5 small 2
6 medium 2
7 large 2
8 extra large 2


Notice how we have used the id_attribute_category as a foreign key. 

Now we need to define which products have specific attributes.  Since we don't want to assume things like all of our t shirts come in the same sizes, or our edibles all come in the same flavors, we need to associate each product with its particular attributes.  This is done in a table called product_attribute.


  • for women's edible panties the id_product = 1
  • for men's edible panties the id_product = 2
  • for the eagle feather t-short the id_product = 10
  • for the sentinel t-short the id_product = 11


id_product_attribute id_attribute id_product
1 1 1
2 2 1
3 3 1
4 4 1
5 1 2
6 2 2
7 3 2
8 4 2
9 5 1
10 6 1
11 7 1
12 8 1
13 5 2
14 6 2
15 7 2
16 8 2
17 5 10
18 6 10
19 7 10
20 8 10
21 5 11
22 6 11
23 7 11
24 8 11


Finally, we have our "unnecessary" table, at least in theory.


id_prod_attribute_category id_product id_attribute_category
1 1 1
2 1 2
3 2 1
4 2 2
5 10 2
6 11 2


We leave initialization of the other tables until we are closer to making use of them.