FQL Overview

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

  • + guest7e4b041 guest7e4b041 8 months ago
    Really a useful one.
    Keep up good work!!
  • + webgoddesscathy MaRS Discovery District 3 years ago
    Craig - really appreciated your presentation. You did a great job on a technical topic. Plus, everyone loves a good potty joke :)
Post a comment
Embed Video
Edit your comment Cancel

9 Favorites & 3 Groups

FQL Overview - Presentation Transcript

  1. FQL
    • Overview of FQL
    • Creating a simple query
    • Using more advanced syntax
    • Differences between SQL and FQL
    • Q & A
  2. FQL: Overview
    • Facebook Query Language introduced in the early spring of 2007
    • F8 appeared a little over two months ago
    • Facebook API calls are just pre-packaged FQL queries
  3. FQL: Overview
    • Key advantages:
      • Common syntax for all methods
      • Condense Facebook queries
      • Reduce response size
  4. FQL: Overview
    • FQL is an SQL-like syntax:
      • SELECT name FROM user WHERE uid = 00000000
  5. FQL: Simple Query
    • Three parts to a query:
      • SELECT a field
      • FROM a table
      • WHERE a condition is met
  6. FQL: Simple Query
    • Where do I live?
      • SELECT current_location FROM user WHERE uid = 00000000
  7. FQL: Simple Query <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <users_getInfo_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd&quot; list=&quot;true&quot;> <user> <uid>503802602</uid> <current_location> <city> Toronto </city> <state> Ontario </state> <country> Canada </country> <zip/> </current_location> </user> </users_getInfo_response>
  8. FQL: Simple Query
    • Has AND , OR , and NOT keywords
    • Does simple math
    • Uses basic boolean operators
      • SELECT uid2 FROM friend WHERE uid1 = 00000000 AND uid2 > (00000000 + 700)
  9. FQL: Simple Query ... <friend_info> <uid2> 00000701 </uid2> </friend_info> <friend_info> <uid2> 00000702 </uid2> </friend_info> <friend_info> <uid2> 00000703 </uid2> </friend_info> ...
  10. FQL: Simple Query
    • Enhance queries with basic functions
    • Examples include:
      • now()
      • strlen()
      • substr()
      • strpos()
  11. FQL: Advanced Query
    • Use functions and math to construct more accurate responses:
      • SELECT location FROM event WHERE eid = 2487044119 AND strpos(name,&quot;facebook&quot;) AND start_time >= 1186536600
  12. FQL: Advanced Query <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <fql_query_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; list=&quot;true&quot;> <event> <location> MaRS </location> </event> </fql_query_response>
  13. FQL: Advanced Query
    • Queries must be “indexable”
    • Restricted by unique IDs, typically a table's primary ID (“uid”, “pid”, “eid”)
    • Without an indexable WHERE condition, expect an error
  14. FQL: Advanced Query ... <error_code> 604 </error_code> <error_msg> Your statement is not indexable - the WHERE clause must contain one of the columns marked with a star in http://developers.facebook.com/documentation.php?doc=fql</error_msg> <request_args list=&quot;true&quot;> <arg> <key>query</key> <value> SELECT name FROM event WHERE strpos(location,&quot;facebook&quot;) </value> </arg> ...
  15. FQL: Advanced Query
    • Subqueries allow very narrow results to be returned
    • Chain queries together with IN clause
    • Limited only by the data itself
  16. FQL: Advanced Query
    • SELECT eid
      • FROM event
      • WHERE eid
      • IN (
        • SELECT eid
        • FROM event_member
        • WHERE uid = 00000000
        • AND rsvp_status = &quot;attending&quot;
      • )
      • AND location = &quot;mars&quot;
  17. FQL: Advanced Query <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <fql_query_response xmlns=&quot;http://api.facebook.com/1.0/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; list=&quot;true&quot;> <event> <eid> 2487044119 </eid> </event> </fql_query_response>
  18. FQL: Advanced Query
    • Some columns contain arrays
    • Example: current_location also holds city , state , zip
    • Usage: work_history.company_name
  19. FQL: Versus SQL FQL != fecal
  20. FQL: Versus SQL but... FQL != SQL
  21. FQL: Versus SQL
    • FQL is designed to be efficient
    • Improving performance means restricting queries
  22. FQL: Versus SQL
    • No JOIN
    • No ORDER BY
    • No GROUP BY
    • No LIMIT
  23. FQL: Versus SQL
    • Limitations may mean too much data is returned
    • Requires more complicated parsing
  24. FQL: Versus SQL
    • Each FROM can only be against one table
    • Not allowed:
      • SELECT * FROM user, photo_tag WHERE uid = 00000000 AND subject = `flower`
  25. FQL: Versus SQL
    • Example: display the 5 most recently updated events in Toronto
  26. FQL: Versus SQL
    • In SQL:
      • SELECT * FROM event WHERE location = &quot;mars&quot; AND user = 00000000 ORDER BY update_time ASC LIMIT 5
  27. FQL: Versus SQL
    • In FQL:
      • SELECT update_time, eid, name, location, venue
      • FROM event WHERE eid
      • IN (
      • SELECT eid FROM event_member WHERE uid = 00000000
      • )
      • AND location = &quot;mars&quot;
    • Then sort the array, and slice it: arsort($result); array_slice($result,0,5);
  28. FQL: Tips
    • Use the developer tools ( fql.query )
    • See what is available by investigating the API documentation
    • Share what you learn on your blog and the developer Wiki
  29. FQL Questions? Craig Saila saila.com [email_address]

+ Craig SailaCraig Saila, 3 years ago

custom

7804 views, 9 favs, 1 embeds more stats

An overview of the Facebook's application query lan more

More info about this document

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Go to text version

  • Total Views 7804
    • 7801 on SlideShare
    • 3 from embeds
  • Comments 2
  • Favorites 9
  • Downloads 0
Most viewed embeds
  • 3 views on http://remarkk.com

more

All embeds
  • 3 views on http://remarkk.com

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories