DB Schema for Facebook, for example Wall + "Shared links"

I am making a db scheme for facebook as a wall structure. I need to save wall posts, share a link, share videos in my database. So far, I can do this circuit:

GO
CREATE TABLE [Wall]
    (
      [ID] [int] NOT NULL IDENTITY(1, 1) ,
      [PostText] [nvarchar](MAX)
      [PostedByUserID] [int] NULL ,
      [PostedOnUserID] [int] NULL ,
      [DateCreated] [datetime] NULL 
    )
GO   

Next, I need to add a scheme to add the "share link" and "share video" features.

GO
CREATE TABLE [Wall]
    (
      [ID] [int] NOT NULL IDENTITY(1, 1) ,
      [WallText] [nvarchar](MAX)
      [PostedByUserID] [int] NULL ,
      [PostedOnUserID] [int] NULL ,
      [DateCreated] [datetime] NULL,

      [SharedLink] [nvarchar](1024)  NULL ,
      [SharedLinkTitle] [nvarchar](512)  NULL ,
      [SharedLinkDesc] [nvarchar](512)  NULL ,
      [SharedLinkImageSrc] [nvarchar](512)  NULL 
    )
GO

Now with this circuit:

1st case: when inserting a wall column, the columns [SharedLink], [SharedLinkTitle], [SharedLinkDesc], [SharedLinkImageSrc] will be inserted as zero, and the remaining columns will have values.

2nd case: when the "shared shared" link is inserted, the "[WallText]" column will be inserted as zero, and the remaining columns will have values.

70% , 30% "" , , 70% [SharedLink], [SharedLinkTitle], [SharedLinkDesc], [SharedLinkImageSrc] null. , , , "shared link" :

GO
CREATE TABLE [LinkShared]
    (
      [ID] [int] NOT NULL IDENTITY(1, 1) ,
      [PostedByUserID] [int] NULL ,
      [PostedOnUserID] [int] NULL ,
      [SharedLink] [nvarchar](1024)  NULL ,
      [SharedLinkTitle] [nvarchar](512)  NULL ,
      [SharedLinkDesc] [nvarchar](512)  NULL ,
      [SharedLinkImageSrc] [nvarchar](512)  NULL 
    )
GO 

, . , ?

+3
2

(/ / ), , .

+5

- , -, . NULL , , .

, , - , , , , , " ":

, . , . : . , , , . , I, .

. , (ID, insertion_date), . , , , . , , " " " ", .

, , : ( , ), , . , : 10 , , 10 .

+2

Source: https://habr.com/ru/post/1765182/


All Articles