0

i'm working on a social network. With activity (like, comment, follow, post, etc...), user, page-to-follow, album, photo and some other thing.

Now, one of the most important things in a social network is the activity feed. I've a structure with activity_feed table, user_table, follow_table, like_table, etc... i was thinking: what if i use a unique AUTO INCREMENT to identify every single entities in my app?

Example:

A user join my site by registration:

  • Add the activity to activity_feed (and obtain an ID)
  • Add the user to user_table (with foreign key to activity_feed)

Example 2:

A user upload a photo:

  • Add the activity to activity_feed
  • Add the photo to photo table (with foreign key)

This will simplify api calls (ex: http://api.domain.com/ID), DELETING entities, future database sharing and many other things.

I notice that facebook have a structure like this. Obviously indexing can be made on other tables (ex: activity_index_type with activity_type -> user and activity_id).

might be a good solution?

Sorry for my english! :$

Monte
  • 1,018
  • 8
  • 15

1 Answers1

0

This is the concept of Globally Unique ID's (GUID). MySQL has a function to generate them : UUID(). And here's a suggestion on SO for storing GUID's

Community
  • 1
  • 1
Andrew
  • 8,363
  • 8
  • 43
  • 71
  • Uh, i know GUID, but i want to know if using INT with that method might be good? Thanks! – Monte May 04 '13 at 08:24
  • The answer I linked to in my answer suggests using a `CHAR(16) binary`. Here's the link again. http://stackoverflow.com/questions/412341/how-should-i-store-guid-in-mysql-tables – Andrew May 05 '13 at 05:46