问题
Describe relationship in maximo 7.5 with all detail including backend database process.
Suppose I create a relationship in maximo 7.5 asset management between owner_group and person_group "owner_group=:person_group" then what is the actual meaning of this query. I am quite confused about it.
Can you please explain what is the process in database?
回答1:
Maximo "relationships" are simply the "where clause" snippet of an SQL statement. The "child object" that you define is the table that "where clause" will be run against.
Maximo's backend always starts out with "select * from ". It will then append your child object's table name (which is almost always the object name itself). Then it appends " where " and your relationship text. In the end Maximo ends up running the query "select * from <object> where <relationship>" against the database. It will then load the results into an MBOSet of <object>s.
It isn't so much a join as it is a jump/switch to another table. Because it isn't a join, the query has no context of the object data you started from. To be able to use data from your originating object to filter down your destination object set, you can use field binds, those "colon fieldname" pieces of the where clause snippet. Maximo will do a find and replace on all of those binds it finds, replacing them with data from the appropriate fieldnames of your starting object. This is where the "parent object" setting of the relationship comes into play. That means Maximo will only run this query if you start from a record of a type equal to the "parent object" so that it knows where those field binds come from.
It might be worth mentioning that a relationship must start from a single object (MBO), not a set of objects (MBOSet) in order to allow this work. However, since a query returns one or more records in its result, you will always get a set of objects back (MBOSet) from the relationship. Also, because this is a find and replace like this before the query is run, Maximo does not take advantage of any database query plan caching feature; each query looks different to the database and is reparsed before being executed.
For example, if you want to create a relationship from Asset to Workorder to get all of the open workorders for an asset, you would do the following: Create a relationship with a child object of WORKORDER because that is the record type you want to get back. You want all open workorders, so you start your relationship text with "status = 'OPEN'". You also only want workorders for the asset you are currently looking at, that means you want to use data from your current object so you need to use a field bind. In this case you want to filter the workorder records whose assetnum is the same your current record's assetnum, that means you add " and assetnum = :assetnum" to your relationship text/where clause (giving you "status = 'OPEN' and assetnum = :assetnum" for your total relationship string). The first assetnum without the colon means it is normal query text and will be run as is. The second assetnum with the colon tells Maximo this is a bind that needs to be replaced. The order doesn't matter, just the colon matters. Maximo will find the assetnum field of your current object (ASSET) and put the contents of that field (say assetnum "Blower0082") into the query in place of the ":assetnum". The end result of this defined relationship when run on this particular asset is that Maximo runs the following query against the database and loads any results into a WORKORDER MBOSet: select * from WORKORDER where status = 'OPEN' and assetnum = 'Blower0082';
Your particular example of owner_group = :person_group doesn't make sense on its own; a parent object (so Maximo knows where to pull bind data from and when it is allowed to execute this query) and a child object (so that it knows what table it is selecting from) are needed too. I'm going to assume this has a parent object of PERSONGROUP and a child object of WORKORDER. Since "person_group" starts with a colon, Maximo is going to replace that string with the contents of the person_group field of your parent object, so the person_group field must exist on your parent object. Since owner_group does not have a colon in front of it, it is normal SQL syntax and therefore that field must exist on your child/destination object. This relationship would get you all workorders that are owned by the persongroup record you have loaded at the moment. Assuming that persongroup is "plumbers", it would run the following query and return all workorders currently owned by plumbers: select * from WORKORDER where owner_group = 'plumbers';
回答2:
You can think of Maximo relationships in the same terms as a SQL join.
In System Configuration > Platform Configuration > Database Configuration -- every object can have relationship associated with a child object.
For example, if your Parent Object is Work Order, I will create a relationship called OWNERPERSON where the Child Object is PERSON.
The Where Clause personid = :owner
means when the Child Object (PERSON) brings a result from the where clause personid = :owner
then the related data can be displayed. :owner
is the variable that is in WORKORDER.
If the :owner
value in WORKORDER is Chip_Drapeau
then you can display any from the PERSON Child Object where personid = Chip_Drepeau
Hope this helps.
来源:https://stackoverflow.com/questions/29114531/describe-relationship-in-maximo-7-5