Data Modeling Attributes - attributes

I just had a quick question pertaining to converting a physical model to a logical model. Is an attribute the same thing as a column, in that, an attribute is just a logical name for column name?

Yes, an attribute corresponds to a named table column. However, an attribute is not a name, rather, as a binary predicate, it has a name, a domain and a range. In the web ontology language OWL, an attribute is called a "data property", since its range is a data type.

Related

How to store a Value Object collection

Suppose I have a User entity. And this entity must have a Country field.
As a rule, Country is a Value Object.
And here it's kind of okay, and there's no problem.
But I got a ticket, which says that now on Frontend, Country must be filled in from the list of available Country (also I need to expand this list in the future)
This would be an easy task if Country was originally an entity, but I have it as a Value Object.
What to do in this case? Redefine Country as an entity, or is there another way?
Even when you maintain Countries as entities, you can store them as part of the User entity as a Value Object. The fundamental nature of a country object is such that its value is its identity, making it a good candidate for a Value object.
But IMHO, the list of Countries can be preserved as a static list because the list is finite.
I don't know what it means for your app to add a country to the list, but I am assuming that it is not as trivial as a CRUD op. If the list is rarely updated, you can maintain the list of available countries as a static list in code that is updated when necessary.
If the requirement is to often switch a country from available to not-available and vice-versa, you can store them as CRUD entities but use them as Value Objects in User.

Core Data - To Many relationship - Table bindings

I have a NSTableView with bindings.
Each row of the table is a Core Data Entity named Entry.
An Entry can have several CustomValue. Each CustomValue should be displayed in its own column in the Table.
I had 2 choices to model this in Core Data:
Choice 1: Either model a dictionary as a Transformable, where the key is the column name & the value is the CustomValue.
Choice 2: Either use a To-Many relation ship Entry <-->> CustomValue <--> key & value where key is a Column entity.
I chose the second solution based on this: Best practice? - Array/Dictionary as a Core Data Entity Attribute
BUT my problem is : with Choice 2, how can I bind the data to the column?
With Choice 1, I could do something like this:
textField.bind(NSBindingName.value, to: cellView, withKeyPath: "objectValue.myDictionary.\(tableColumn!.identifier.rawValue).value", options: nil)
I'm currently stuck, I need to map a binding to something that would allow me to search for the proper value based on the key.
Any idea? Thanks in advance :-)

Acumatica Formula for Dividing 2 values

I am trying to divide values and display it in a new custom field(usrQuantity)on Stock Items Screen.
I want to divide OpenQty (which is a column in POLine) and CARTONQTY(which is not a column name but just an attribute in column AttributeID in CSAnswers table).
enter image description here
I am confused how to perform this division since CARTONQTY is not a field, I noticed that there is a field named CARTONQTY_Attributes in InventoryItem table which has been generated by some Join queries but is not actually present in the Database(checked in SQL Management Studio).
enter image description here
I tried this formula in the DAC of usrQuantity
[PXDBInt]
[PXUIField(DisplayName="Quantity")]
[PXFormula(typeof(Div<POLine.orderQty,InventoryItem.CARTONQTY_Attributes>))]
But it is giving following errors
The type or namespace name 'POLine' could not be found (are you missing a using directive or an assembly reference?)
The type name 'CARTONQTY_Attributes' does not exist in the type 'PX.Objects.IN.InventoryItem'
Do you want to store the value in the db? Typically it's not recommended practice to persist calculated values unless, for example, there's a performance issue in performing the calculation on the fly. If you don't want to store it, you probably want a PXInt instead of PXDBInt. Also, unless you always expect a whole number as a result of your division (which is unlikely), you should probably use a PXDecimal type.
To then get your calculated value into your new field, I would probably set it in RowSelecting and RowUpdated event handlers by extending the appropriate PXGraph class; in order to calculate it as you retrieve a row and when you update the row values.

How to avoid dataset from renaming columns to value while mapping?

While mapping a dataset I keep having the problem that columns are being renamed from _1, _2 ect to value, value.
What is it which is causing the rename?
That's because map on Dataset causes that query is serialized and deserialized in Spark.
To Serialize it, Spark must now the Encoder. That's ewhy there is an object ExpressionEncoder with method apply. It's JavaDoc says:
A factory for constructing encoders that convert objects and primitives to and from the
internal row format using catalyst expressions and code generation. By default, the
expressions used to retrieve values from an input row when producing an object will be created as
follows:
- Classes will have their sub fields extracted by name using [[UnresolvedAttribute]] expressions
and [[UnresolvedExtractValue]] expressions.
- Tuples will have their subfields extracted by position using [[BoundReference]] expressions.
- Primitives will have their values extracted from the first ordinal with a schema that defaults
to the name `value`.
Please look at the last point. Your query is just mapped to primitives, so Catalyst uses name "value".
If you add .select('value.as("MyPropertyName")).as[CaseClass], the field names will be correct.
Types that will have column name "value":
Option(_)
Array
Collection types like Seq, Map
types like String, Timestamp, Date, BigDecimal

SSAS, dimension numeric value filtering

I am using the multiple dimensional model in SSAS with a seemingly simple requirement.
I have a Product dimension table with a Price attribute. Using Excel pivot-table, I want to filter this Price attribute, for example "greater than $1000". However the filter in the pivot table is a string only, hence I can not do perform any numerical comparison operations, but rather for equivalent strings, e.g. "$1,000.00".
My problem is similar to this thread, and I wonder if there is a solution/work around that I missed?
Best regards,
CT
As suggested in the thread that you link, you could create a measure for the price, and then filter that. The definition of this calculated measure would be something like
[Product].[Product].Properties("Price", TYPED)
assuming the dimension as well as the attribute are named "Product", and the attribute has the price defined as a property named "Price".
(You define a property in BIDS as a relationship from the Product attribute to the Priice attribute.)

Resources