Is this a good use for Single Table Inheritence?

Hi everyone,

Where I work, there are several standards (heh) for position codes for
staff and faculty. For instance, a Dean could be listed as DEA or
DEN. An Assistant Professor could be AST or ASO. There are some
cases where typos have crepts into the system, and AS0 (zero) could
have meant ASO.

Now, beyond getting those responsible to clean up their data (we are),
I need to deal with this now. I was hoping Single Table Inheritence
would help me.

For all legit codes (you know, the ones IT standardized on), we could
have an id, code, and description. Simple stuff:

id: 1
code: AST
description: Assistant Professor

For the discrepencies, there would be an additional column pointing to
the code it really is.

id: 2
code: ASO
parent: 1 (A better name for this would be great, but you ge the idea.)

So, what would be the best way to apply a code to someone? Write a
custom find_by_code that returns the code if it has no parent and the
parent code if it does?



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs