0

Actually i m creating a kind of social network for learning, where user can share photo and links, i m using mysql as datastore, both types of post(later i can add more types as well ex- videos etc) can be liked and can have comments, so i created a parent entity table,

Table : Entity 
  id : 'Primary key'

and

Table : Links
  id : 'Primary key'
  entity_id : 'FK'

now when i create newsfeed, how i will be able to fetch links and photos by entity table ?

mean

Select * from Entity 

will just give entity ids, but how to know is that link or photo or which table to query next ??

Will I have to add a Type column to Entity table? Or another solution join etc? I don't know about them, so just give me that term i will check that on internet, thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vikas Yadav
  • 309
  • 3
  • 6
  • 1
    Possible duplicate of [How can you represent inheritance in a database?](https://stackoverflow.com/questions/3579079/how-can-you-represent-inheritance-in-a-database) – philipxy Nov 13 '18 at 07:13
  • "types of" = "subtypes of". "parent entity [type] of" = "entity supertype of". – philipxy Nov 13 '18 at 07:14

0 Answers0