O'Reilly logo

PHP 5 Social Networking by Michael Peacock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom relationships

Before we can connect to a user as a friend, we need to define the types of relationship our social network will support. Within Dino Space, we should have relationships for:

  • Friends: For users who are friends with one another
  • Colleagues: For users who are colleagues with one another
  • Jogging buddies: For users who take their dinosaurs to the same morning jogging group

We may, of course, wish to extend this as the site grows and changes as time goes on.

To facilitate these relationships we are going to need two database tables, one to maintain a list of types of relationships, and one to maintain a list of relationships between users.

Relationship types

To represent the relationship types in the database, we could use the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required