Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7006877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:32:03+00:00 2026-05-27T21:32:03+00:00

I have an entity Content, with relation to either FileImage or FileVideo. What is

  • 0

I have an entity Content, with relation to either FileImage or FileVideo. What is the proper way of doing this in Doctrine 2?

Content should relate to FileImage or FileVideo, never both, and never none.

What’s a working example to solve the above using annotation syntax?


Or maybe I’m looking at this the wrong way?

My design idea; Files are stored using MogileFS which keeps multiple copies of each file on a subset of servers indexed on filenames. FileVideo contain a list of filenames for different properties (thumbnail, resized etc.) which are different based on file type (E.G FileVideo and FileImage). Paths to the files themselves would be loaded by FileVideo relation to MogileFS mapper outside of Doctrine 2. Business logic should only concern itself with Content model containing ref

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:32:04+00:00Added an answer on May 27, 2026 at 9:32 pm

    Consider some kind of inheritance. FileVideo and FileImage could be subclasses of some parent Entity “File”, and your Content entity would have @OneToOne or @ManyToOne relation to “File”. You’d be left to your own devices to ensure that Content.file is not null.

    Note that there’s a tradeoff deciding between class-table and single-table inheritance implementations in this case. CTI will deliver a more normalized schema, and is arguably more flexible if your inheritance graph is likely to grow, but will force doctrine to always eager-load the relation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I am using the Linq entity framework. I have 2 entities: Content and
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I have a thought provoking question, in relation to the use Entity Framework (EF)
I'm have an issue with this entity query that I am hoping to get
I have an entity class, correctly defined in a managed context. This class has
I have an entity like this: @Entity @XmlRootElement public class Article { @Id @GeneratedValue(strategy
I have entity Order witch has @OneToOne relation to second entity File , relation
I have an Entity. Mandate . Every mandate has a required:many relation to a
I have an abstract Content entity in my EF4 model with a concrete subclass,
Setting up ASP.net MVC with Linq2SQL or Entity Framework's context to have scaffolding work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.