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

  • Home
  • SEARCH
  • 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 137587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:07:46+00:00 2026-05-11T07:07:46+00:00

If you were trying to create a domain object in a database schema, and

  • 0

If you were trying to create a domain object in a database schema, and in your code said domain object has a hashtable/list member, like so:

public class SpaceQuadrant : PersistentObject {      public SpaceQuadrant()     {     }      public virtual Dictionary<SpaceCoordinate, SpaceObject> Space     {         get;         set;     } } 

A Dictionary is just a hashtable/list mapping object keys to value keys, I’ve come up with multiple ways to do this, creating various join tables or loading techniques, but they all kind of suck in terms of getting that O(1) access time that you get in a hashtable.

How would you represent the SpaceQuadrant, SpaceCoordinate, and Space Object in a database schema? A simple schema code description would be nice, ie.

table SpaceQuadrant {     ID int not null primary key,     EntryName varchar(255) not null,     SpaceQuadrantJoinTableId int not null                  foreign key references ...anothertable... } 

but any thoughts at all would be nice as well, thanks for reading!

More Information:

Thanks for the great answers, already, I’ve only skimmed them, and I want to take some time thinking about each before I respond.

If you think there is a better way to define these classes, then by all means show me an example, any language your comfortable with is cool

  • 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. 2026-05-11T07:07:47+00:00Added an answer on May 11, 2026 at 7:07 am

    First, dedicated support for geo-located data exists in many databases – different algorithms can be used (a spatial version of a B-Tree exists for instance), and support for proximity searches probably will exist.

    Since you have a different hash table for each SpaceQuadrant, you’d need something like (edited from S.Lott’s post):

    table Space {     SpaceCoordinate,     Quadrant Foreign Key SpaceQuadrant(ID),     SpaceObject -- whatever the object is (by ID)     Primary Key(SpaceCoordinate, Quadrant) } 

    This is a (SpaceCoordinate, Quadrant) -> SpaceObjectId dictionary.

    =====

    Now, about your O(1) performance concern, there is a lot of reasons why it’s wrongly addressed.

    You can use in many DB’s a hash index for memory-based tables, as somebody told you. But if you need persistent storage, you’d need to update two tables (the memory one and the persistent one) instead of one (if there is no built-in support for this). To discover whether that’s worth, you’d need to benchmark on the actual data (with actual data sizes).

    Also, forcing a table into memory can have worse implications.

    If something ever gets swapped, you’re dead – if you had used a B-Tree (i.e. normal disk-based index), its algorithms would have minimized the needed I/O. Otherwise, all DBMS’s would use hash tables and rely on swapping, instead of B-Trees. You can try to anticipate whether you’ll fit in memory, but…

    Moreover, B-Trees are not O(1) but they are O(log_512(N)), or stuff like that (I know that collapses to O(log N), but bear me on this). You’d need (2^9)^4 = 2^36 = 64GiB for that to be 4, and if you have so much data you’d need a big iron server anyway for that to fit in memory. So, it’s almost O(1), and the constant factors are what actually matters.
    Ever heard about low-asymptotic-complexity, big-constant-factor algorithms, that would be faster than simple ones just on unpractical data sizes?

    Finally, I think DB authors are smarter than me and you. Especially given the declarative nature of SQL, hand-optimizing it this way isn’t gonna pay. If an index fits in memory, I guess they could choose to build and use a hashtable version of the disk index, as needed, if it was worth it. Investigate your docs for that.

    But the bottom line is that, premature optimization is evil, especially when it’s of this kind (weird optimizations we’re thinking on our own, as opposed as standard SQL optimizations), and with a declarative language.

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

Sidebar

Related Questions

I am trying to create a rewrite rule that accomplishes two things: Redirect (www.)?domain.com
Trying to create a user account in a test. But getting a Object reference
Trying to create a list to return some JSON data to a view. Following
I'm trying to dynamically create domain objects in Grails and encountered the problem that
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create my first iPhone app that would play back audio. When I
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
Trying to create a small monitor application that displays current internet usage as percentage
I'm trying to create a bookmarklet for posting del.icio.us bookmarks to a separate account.

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.