What inheritance mapping strategy would you use here, if any?

[Scenario]
I have a somewhat unusual problem. I have a set of entities, like Movie, Book etc. that all inherit Item class and that are perfectly identical in their structure (as none of them has any specific fields on it's own). They all have Id, Name, Description and Image fields, nothing else. The only difference between them is that some, obviously, represent movies, some of them books etc. If I didn't need to know their type, I wouldn't need inheritance at all.
[SINGLE_TABLE]
Obviously, all these entities could be easily persisted into the same table with a discriminator column (and entities themselves would have a @DiscriminatorValue) i.e using SINGLE_TABLE strategy. But, I would avoid this approach as there will be a lot of persisted entities, like, tens of thousands of each type (which means tables that map M-M relations could have millions or tens of millions of rows), so I'm guessing this approach would kill the performance.
[JOINED]
JOINED strategy has the same problems as SINGLE_TABLE.
[TABLE_PER_CLASS]
My opinion here, is that TABLE_PER_CLASS strategy would be the best approach, as I will rarely, if ever, query across multiple types. Item (the supertype) has only unidirectional 1:M relations, so , if I get this right, this is OK as well, as it avoids UNION when queried (please confirm or correct me on this), e.g. the query to fetch books and their votes (1:M) would resolve to SELECT * FROM Book b JOIN Vote v ON b.id = v.item_id, so no UNION... right?
But maybe I don't need inheritance mapping at all then...
What is your opinion here? Any shared thoughts are appreciated.

The disadvantage of using table_per_class would be that you have to duplicate the field structure many times (e.g. code duplication). If you ever want to change certain fields you (or the db-administrator) would have to do that a few times. Since in eventually you always have to use direct sql one time or another, making the database design as clear as the java code (where you wouldn't want code duplication either). Direct SQL you'd often need for optimilazition or because certain operations can be done in one SQL query, while requiring a lot of code if done in java.
You could use a single table, without losing performance. If you add an index to the discriminator type, a modern database will optimize queries and won't to full table scan. That way you have a clean database design, without losing performance.
If you ever need extra fields for say movie that you don't need for book (like duration in minutes, director), you can then create an extra table movie that contains only the fields that are extra. Retrieving movie then requires a join of item and movie, but since movie would be a smaller table and the join will be on indexed field, that wouldn't hurt performance.The database design keeps being clear and readable, as well as your java code.
If you really don't care about your relational database design, don't use a relation database but rather an object database. Object database are optimized for retrieving object graphs (retrieving a graph of objects won't require joins and table scans). The only disadvantage, aggragation of data is usually slower.

Similar Messages

  • What kind of printer would you use to print on a lorry?

    Hi,
    One of my client sells items from the lorry, so he wants his drivers to print invoices on the way. My question is what kind of printer would you use to print on a lorry? Any idea, experience?
    Thx in advance,
    Laci

    Hi Laci,
    There are quite a few mobile printers, for example HP does a range of battery powered Officejet printers which you could use on the go. For instance, check this out:
    http://www.shopping.hp.com/product/CB026A%2523B1H
    I hope this helps!
    xx Nat

  • What command would you use to check for allocation, structural, or logical integrity problems?

    What command would you use to check for allocation, structural, or logical integrity problems?

    Wondering if you are looking for DBCC CHECKDB command? For more information, on that command, try to look at this:
    http://technet.microsoft.com/en-us/library/ms176064.aspx

  • What sequence setting would you use to edit 1280 x1080 DVCProHD (P2) and 1920 x 1080 AVCHD (Sony) in FCP. Experiencing Quality and rendering issues.

    What sequence setting would you use to edit both 1280 x1080 DVCProHD (P2) and 1920 x 1080 AVCHD (Sony) in a single timeline in FCP. I'm experiencing quality and rendering issues.  I've tried numerous settings but can't seem to figure this one out.  Thanks for your assistance.

    Although you can combine the avchd 1920x1080 material with prores 1920x1080 in the same timeline, you might land up saving time just converting everything to 1920x1080 prores 422.   You'd probably reduce the amount of rendering while you're working and exporting when you're done by a great deal.  This workflow will require much more drive space.

  • What version of windows would you most recommend using?

    what version of windows would you most recommend using?
    XP Home, XP Professional, Vista Home, Vista Business?
    I see that XP takes up 1.5GB versus Vista's 20GB. XP uses 128MB Ram versus vista 512MB.
    It would seem like XP would run faster and take up less space... but is it the best choice? Thanks for the suggestions.

    Jonny Apple Seed wrote:
    What's the best place to buy windows xp professional cheap? the disc I had for my old pc is Sp1, which wont work with bootcamp.
    Windows XP Home
    Windows XP Professional
    iFelix
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • What camera raw default settings would you use for the Canon 5D Mark 3. I have PS CS6.  Thank you.

    What camera raw default settings would you use for the Canon 5D Mark 3. I have PS CS6.  Thank you.

    Really, this is a question you should be asking yourself...
    What do you shoot? Makes a difference...
    Typical ISO that you shoot? Makes a difference...
    Shooting for clients or yourself? Makes a difference...
    Look, there is no magic bullet...the ACR/LR "Default" should only be changed for those adjustments you make 70-90% of the time and sould not be confused with image by image adjustments...
    So, as asked, your question can not really be answered other than to say, use a default that suits you.

  • What would you use to clean a USB female connector on a TP X200?

    I accidentally spilled some thick sugary drink in there which dried up. What would you use to make it usable again?Thanks.

    Try a cotton swab dipped in isopropyl alcohol. Make sure to remove the power supply and battery and have plenty of swabs on hand. Don't soak the connector

  • Is it possible to rip itouch to pc? If not what 3rd party program would you recomend?

    My pc crashed and i lost my music libary. now i have all music still on my itouch but not sure if i can rip off it.  so if theres a 3rd party program that can do this what one would you use?

    To copy the settings and data to your new iTunes library try this:
    Make sure your computer is still authorized in iTunes. Disable autosync in iTunes, connect your iPod, right click on it in the device list and choose backup.
    This will save data, pictures and settings to itunes. See what's included in this backup here: http://support.apple.com/kb/HT4946
    Transfer your purchases the same way to copy all apps and bought media from the Store to your computer.
    Set up at least one contact and event on your computer to be able the merge your calendars and contacts after your iPod got wiped during the first sync.
    The rest of the data can be restored from the backup you made.
    Restoring: http://support.apple.com/kb/HT1414
    Music is one way only, from the computer to your device, unless you bought the songs in iTunes and transferred your purchases.
    There is 3rd party software out there, but not supported by Apple, see this thread: http://discussions.apple.com/thread.jspa?threadID=2013615&tstart=0

  • What trusted web sites do you use that have free or purchase photoshop brushes?

    What trusted web sites do you use that have free or purchase photoshop brushes?

    The size and resolution depends on the intended output.
    In my opinion relevant zooming shortcuts would be cmd-0 (View > Fit on Screen), cmd-1 (View > 100%) and cmd-spacebar/cmd-alt-spacebar to temporarily switch the current Tool to the Zoom Tool.

  • What world traveler adapter do you use when traveling in India?

    What work traveler adapter do you use when traveling in India?

    I didn't mean my reply as a rant! Just welcoming another disabled guy on board. Yes, I do budget - and have enough left over to buy software and hardware for my Mac. The 'government' doesn't pay my electric bill - I do - and I pay $460 a month in rent - and I live in a very nice, unsubsidized handicapped and wheelchair accessible apartment.
    You really need to work on your anger issues - and although I, too, believe in an afterlife, I can be happy in life just as I am: I've no legs, so getting around is difficult for me but I don't let that stop me from enjoying life.
    I've no family remaining save for an uncle and aunt and some cousins - and they're all in Texas. And, although I, too, was "dumped" by most of my middle-class friends, I have a handful of friends on whom I rely.
    I don't believe that suicide is a way out, either. My own step-mother blew her brains out after she had a stroke. She was on massive amounts of antidepressants but she took her own life. That way is not for me.
    Loosen up and open up a little - I'm sure that you can find something in common even if it's with others who may be disabled. I do some volunteer work with a couple of agencies in town and find that keeps me going - and keeps me from feeling sorry for myself.
    If you need anyone to 'talk' to at anytime, just click on my name and my profile with my email address is public. Email me if you like...
    And have a Happy New Year - and be thankful that you got your computer as a gift!
    Clinton

  • What type of pen do you use to take notes on a notetaking app like enotebook

    What type of pen do you use on your ipad for a handwriting app like enotebook?

    You want what's called a stylus. There are a huge variety of styli available; just make sure that the one you get works with iPad (pretty much all of them will say they work with iPad on the packaging). I personally just grabbed the cheapest one at Staples, but you can see a bunch of styli here: http://www.theverge.com/2012/4/10/2925937/best-stylus-ipad-review

  • What apple store app would be used to read emails on mac that were downloaded to a thumb drive from windows (outlook).

    What apple store App would be used to read email on the mac that was downloaded to a thumb drive from windows outlook.
    Recently purchased a Mac and data transfer for e-mails only showed the email preview but does not open up the body of the email or attachments.  So I down loaded my inbox, and folders to a thumb drive.  this will open correctly on the window pc but the mac is looking for the approriate app to read this data.
    Could the Apple store remove down loaded emails and then reload from the thumb drive?

    EL-Benjo,
    Please be sure to read the Important Note at the bottom of the page of the link I provided.
    Important Note
    When you install OS X Lion using the USB thumb drive, you will not be able to reinstall OS X Lion from Lion Recovery. You will need to use the USB thumb drive to reinstall OS X Lion.

  • You want to know the amount of space the transaction log for the Customer database is using. Which T-SQL command would you use?

    You want to know the amount of space the transaction log for the Customer database is using. Which T-SQL command would you use?

    Forced me to do a little research.
    DBCC SQLPERF(logspace)
    See also
    http://stackoverflow.com/questions/198343/how-can-i-get-the-size-of-the-transaction-log-in-sql-2005-programmatically
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Which interface would you use to list each element of a vector?

    Which interface would you use to list each element of a vector?

    The laugh's on you, twit! Nobody takes kindly to lazy bums trying to cheat on their homework nor exams. Take a hike loser!

  • Which statement would you use to confirm a transaction?

    Which statement would you use to confirm a transaction?
    a. COMMIT TRANSACTION
    b. ROLLBACK TRANSACTION
    c. CHECK TRANSACTION
    d. VIEW TRANSACTION

    a.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

Maybe you are looking for

  • Set and Get parameters using SAP memory.

    I have an ALV grid list that I want to transfer to a detail report when the user doubleclicks.  I have set up a parameter transaction associated with the detail report.  My problem is the transfer does not take place.  After the "CALL TRANSACTION" th

  • Spry menu Bar I.E. positioning issues?

    Hi, I, like many folks I've seen on various forums have the same problem with my spry menu appearing at the top of I.E browsers instead of under the menu bar. I've tried all sorts of fixes that I've found and have updated to the latest version of Spr

  • Windows Vista Installation on New Intel Mac

    I bought a full version of Vista about two years ago. I removed it from the Intel Mac I had originally installed it on. Indeed, I've replaced the HD it was on, but for reasons other than removal of Vista. I installed Vista successfully on a new Intel

  • 32 bit Oracle server installation on 64-bit Linux box

    Hi All, I would like to know if it is suggested to install 32 bit oracle software on a 64 bit Linux box. Details of our new DB box below: $ cat /etc/SuSE-release SUSE LINUX Enterprise Server 9 (x86_64) VERSION = 9 PATCHLEVEL = 4 $ free -m total used

  • How to change screen brightness on bootcamp 5.0.2 in Windows 8?

    I have a retina MacBook Pro which i used bootcamp to install windows 8 on. However, i cannot change the brightness with my F1/F2 key. Any solutions?