O'Reilly logo

Facebook Cookbook by Jay Goldman

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

Page Fan Table

Problem

What’s the schema for the page_fan table?

Solution

The page_fan table records the relationships between pages and users. Its fields are listed in Table 8-15. Queries to this table will only return data the current user is allowed to see (i.e., you can’t request fans for pages that the current loggedinuser can’t see). More information about this table, including an up-to-date listing of fields, can be found at http://wiki.developers.facebook.com/index.php/Page_fan_(FQL).

Table 8-15. page_fan table fields

Name

Type

Index

Description

uid

int

User ID of this user.

page_id

int

 

Page ID of the Page the user is a fan of.

type

string

 

Type of this Page. There are a way too many different Page types to enumerate here. You can see them on the Create a Page page (http://www.facebook.com/pages/create.php). They’re generally stored in the database in all caps, with underscores in place of spaces (e.g., CONSUMER_PRODUCTS).

Note that only the field marked as “Index” in this table can be used in an FQL query’s WHERE clause, but any of the fields can appear in the SELECT.

Discussion

There’s a really obvious index missing from this table, which makes working with it a whole lot harder: page_id (although the field exists, the lack of an index on it means you can’t include it in FQL queries as part of the WHERE clause). As it currently stands, you can find the Pages a user is a fan of but not the users who are fans of a Page. It would fit better with the general FQL model to enable that index ...

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