To understand the relationship more clearly, you can get a picture by using database diagrams.
A number of tools allow you to build database structures visually, implement them physically
in the database for you, and generate the necessary SQL script. Although we won??™t present
any particular tool in this book, it??™s good to know that they exist. You can find a list of the most
popular tools at http://www.databaseanswers.com/modelling_tools.htm.
Database diagrams also have the capability to implement the relationships between
tables. For example, if you had implemented the relationships among your four tables so far,
the database diagram would look something like Figure 5-6.
Figure 5-6. Viewing tables and relationships using a database diagram
department epartment
PK department_i epartment_id
name
description cription
cate category ory
PK
FK1
cate category_i ory_id
department_i epartment_id
name
description cription
pro produ duct_cate ct_category ory
PK, FK2
PK, FK1
pro produ duct_i ct_id
cate category_i ory_id
department epartment
PK pro produ duct_i ct_id
name
description cription
price
disco counte nted_price
_ima image
ima image_2
e_th thumbnail nail
display play
CHAPTER 5 ?– CREATING THE PRODUCT CATALOG: PART 2 124
In the diagram, the primary keys of each table are marked with ???PK.??? Foreign keys are
marked with ???FK??? (because there can be more of them in a table, they??™re numbered).
Pages:
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217