Prev | Current Page 190 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"


So, now that you know the data you want to store, let??™s think about how the three parts
relate to each other. Apart from knowing that the records of two tables are related somehow,
you also need to know the kind of relationship between them. Let??™s now take a closer look at
the different ways in which two tables can be related.
Relational Data and Table Relationships
To continue exploring the world of relational databases, let??™s further analyze the three logical
tables we??™ve been looking at so far. To make life easier, let??™s give them names now: the table
containing products is product; the table containing categories is category; and the last one is
our old friend, department. No surprises here! Luckily, these tables implement the most common
kinds of relationships that exist between tables, the one-to-many and many-to-many
relationships, so you have the chance to learn about them.
?– Note Some variations of these two relationship types exist, as well as the less popular one-to-one
relationship. In the one-to-one relationship, each row in one table matches exactly one row in the other. For
example, in a database that allowed patients to be assigned to beds, you would hope that there would be a
one-to-one relationship between patients and beds! Database systems don??™t support enforcing this kind of
relationship, because you would have to add matching records in both tables at the same time.


Pages:
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202