It looks like you use bundles for relationship types, which implies that different relation types can have different fields. If so, COOL.

If I attach fields to a relation type, then it is a field instance. The actual field could then be attached to other relation types, since they're different bundles. This would still honor the entity_type, bundle, field uniqueness constraint.

Question 1: Am I OK so far?

Use case:

I'm using different relation types to enter conversion factors, which requires both (subject_qty, subject_units) and (object_qty, object_units) pairs. I would like to be able to create a "units" field which is a taxonomy term reference for a vocabulary of units. For example, I could have a taxonomy term hierarchy such as:

physical units > length > metric > meters
physical units > length > imperial > feet
physical units > time > all > hours
physical units > time > all > minutes
physical units > time > all > seconds
etc.

I could then reuse this "units" field anywhere I wanted, including Relations.

Question 2: Still OK?

Use case extension:

If I added the qty and units fields for both subject and object, it would allow me to establish a relation such as:

subject_qty subject_units subject content type subject content node relation type object_qty object_units object content type object content node
4 minutes activity car idling has carbon footprint 2.35 kg compound CO2

Question 3: Conceptually speaking, did I make it to the finish line, or did I crash and burn?

Question 4: Practically speaking, is there anything in the dev version of the Relation module that would get in my way?

Comments

naught101’s picture

Title: Attaching fields to Relations » Attaching fields to Relation types

Q1: Yep, all correct.

Q2/3: Sounds right, interesting use-case! Are you planing on using to do calculations? something using http://drupal.org/project/views_calc perhaps?

Q4: No, not for testing. Don't rely on it with important data yet though. Once the first beta is out (should be fairly soon), we'll start adding hook_updates so data will be safer between versions (no guarantees until 1.0 though ;) )

kirkilj’s picture

Thanks for the quick replies. It really does make a huge difference. I'm at a critical juncture in my Drupal learning curve. I'll either move gracefully onto the next level of my journey in the next couple days or spontaneously combust.

I don't mind blowing stuff away and recreating things, so the dev branch of Relation is fine for my purposes. I installed the Drupal Quickstart virtual image with Virtual Box, which has a complete Ubuntu installation with the usual suspects (Apache, PHP, MySql, Drupal, APC), but also includes Drush, X-Debug integration with NetBeans or Eclipse, as well as XHProf and Webgrind for profiling. With the VM, I can take a snapshot anytime I feel like I've made progress, and revert if things blow up horrifically. I'm probably learning more than I want by single-stepping through core and contrib code. ;)

Yes, I do plan to do all sorts of calculations and queries using relations, some at insert time and some during cron runs that would crawl through compatible relations. I doubt I'll wander into backtracking, but I do want to discover 2nd, 3rd, or 4th order relations.

naught101’s picture

Status: Active » Fixed

Awesome, that sounds great. If you find any features that you need, please open issues, even if they don't fit in relation core, we can help with direction for dependant modules.

Not sure what you mean by "2nd, 3rd, or 4th order relations", but if you mean finding recursively finding relations from a starting point, that's something we want to add.

Since the original questions are answered, I'll call this fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.