简体   繁体   中英

How should I model a horses pedigree in Mongodb?

I'm trying to model a horses pedigree in mongodb.

在此处输入图片说明

I've conducted some research on the internet and have uncovered several potential approaches:

  1. Array of ancestors
  2. graph
  3. simple relationships {_id: "Cigar", sire: "Palace Music", dam: "Solar Slew", Sire's Sire: ...}
  4. Tree Structure with Nested Sets

I'm hoping to get input from some more with experience than me on both the tradeoffs of various approaches given my use cases below:

My use cases follow:

  • Presentation : I will want to display or give the user the option to display the horses pedigree anytime a user queries a particular horse.
  • Traverse/Query: The ability to easily traverse or query the pedigree (by ancestry) to return a particular horse in the pedigree (ie return all broodmare sires wit one offspring with more than 5 turf wins)
  • Performance : Its imperative that pedigree queries are very performant.
  • Ratings : use the pedigree data in conjunction with race results to develop pedigree ratings. strong text
  • Analysis : I will want to conduct analysis on horses pedigrees relative to win and may try to answer such questions as:

    • Is a horse with Northern Dancer as his great grand sire more likely to win its first turf race.
    • What are the Top 10 Sires (Dams, Grand Sires or Grand Dams) for producing winner on a yielding turf course.

Additional information: I plan on developing this application on the MEAN stack.

Thanks for your input.

The data you have is very clearly a binary tree structure. Each horse is a node in the tree, with two child nodes representing the horse's parents (ironic!)

Tutorial: Model Tree Structures in MongoDB . You can insert each horse (starting furthest up the ancestry chain) with a list of the ids for the horse's "children" (which are the horse's dam and sire).

I admit that I'm not familiar enough with MongoDB to give you specific code for your DB queries, but as Mongo is capable of hierarchical data storage, a tree should offer few to no problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM