Bir facebook likenews ve güncellemeleri oluşturmak istiyorum

2 Cevap php

Ben basit bir sosyal ağ sitesinde wokring ve ben basit bir haber güncelleme besleme oluşturmak istiyorum. Gerçek anlamda değil Yem ama birinin bir resim gönderdiğinde zaman facebook örneğin olsun o küçük raporları gibi ana sayfasında söyleyerek basit bir rapor almak biliyorum ki - ve böylece bir resim, ya da öylesine eklenmiş ve bu yüzden bir yorum ekledi. Böyle bir gömlekleri gibi şeyler.

Ancak benzer bir şey inşa etmek istiyorum. Ben bütün tabloları bir sendika dayalı sorguyu çalıştıran düşünüyordum ama o delicesine pratik değildir. Ben başka bir fikir gibi alanlar olurdu bir haber besleme tablo oluşturmak için oldu:

Kim - Aksiyon - NE ÜZERİNE

Where 'WHo' - refers to the user ID of the individual who did something Action refers to the action ie.. adding a comment WHAT refers to like if the action was done ON something like a comment passed on an article.

Ben bunun iyi bir fikir olup olmadığını pek emin değilim ... Ancak ben basit bir çözüm istiyor - herhangi bir fikir çok takdir.

2 Cevap

Ben bu tür size öğeler üzerinde yapılacak bekliyoruz eylemlerin ne tür bağlıdır düşünüyorum. Ben uzman değilim, ama ben alacağını yaklaşımı farklı, her eylem tutmak için olduğunu düşünüyorum.

Kullanıcı size yem görüntülemek için haber var ve kullanıcılar (hatta sadece bir la Facebook onları 'gibi') onlara oy veya madde hakkında bir yorum ekleyebilirsiniz varsayalım.

Ben büyük olasılıkla gibi benim veritabanını kurmak istiyorum:

NewsItems
---------
NewsId
UserId (if this is like Facebook where it's someone posting their item)
Body
Timestamp

Votes
-----
VoteId
NewsId
UserId
VoteType (or possibly VoteValue with values +1 and -1 or something)
Timestamp

Comments
--------
CommentId
NewsId
Body
Timestamp

Bunu kullanarak, bir kullanıcı NewsItems tablodan yayınlanan son n öğeleri alabilir ve her göstermek gibi, bunu Oy tablosundan mevcut oy sayısı bulunuyor belirlemek için bu NewSID bulunuyor kullanın ve aynı zamanda kronolojik bir listesini almak için NewSID kullanabilirsiniz tüm yorumları öğe üzerinde yaptı.

Ben de NewsType ve typeid gibi iki diğer alanları ile NewsItems yılında Vücut alanını değiştirin varsayalım. Eski söyler hangi tablo muhtemelen resim BLOB'ları ve aynı alan / tablodaki durum güncelleme metni istemiyorum çünkü (bir eylem arama için kullanılacak., Ikinci tablodaki arama için size anahtar verir.

Sadece benim iki sent. Umarım yardımcı olur.

thats a tricky and not so easy thing to do. I worked for a start up social network and it was something they wanted as well. I dont think i still have the code laying around but if i recall correctly i went about it something like this

DB:

USERS

id : guid "a unique identifier for this user" "other user info"

ACTIONS

when : unix_timestamp who : guid "the user who made the actions guid" type : set('image','news') "replace with a list of the type of things you want to track" what : url "not like a web address but the guid of the thing that was made"

FRIENDS

id1 : guid "one of the 'friends' guid's id2 : guid "the other persons guid

PHOTOS

id : guid "a unique identifier for the image" url : varchar(255) "where is the image stored (file name directory etc) who : guid "the user who posted the photos guid" "other info you want to keep track of"

NEWS (think status update)

id : guid "a unique identifier for this statu update" who : guid "the guid of the person who posted this" when : unix_timestamp "timestamp of when it was posted what : text "the contents"

using the above structure i would have my code make an entry into the ACTIONS table anytime a user posted a photo or a status update. then when their friend logged on it would go through the ACTIONS table pulling out all the actions of anyone it found was friends (via the FRIENDS table) the TYPE field is used to differentiate what table to use when linking the IDs of the actions. so if the person posted an image when it writes the action to the screen it can set the link up to point to whatever script your using to display images. etc etc

i kod bulabilirsiniz eğer hasta ben hasta gönderebilirsiniz eğer (şirket altında gitti ve ben kod sahipliğini korumak), bkz

Benim açıklama net değilse hasta daha sonra daha iyi bir belgenin süreci ve kod için biraz daha zaman alabilir.