I have a scenario where I have a few products that are sold during an event. These products are configured once and can be used at any event. I currently have the following nodes/relationships:
event-[:HAS_CURRENT_INVENTORY]->inventory-[:OF_PRODUCT]->product
The inventory here is for a single product, so I have a number of these for each event. When a transaction occurs, I want to maintain a snapshot of inventory across all products that I sell at the event. I am currently thinking of doing it this way:
Create a new transaction node
Create new "inventory" nodes for all of the inventory items included in this transaction with new inventory count
Link the new transaction node to all the "current" inventory nodes (not just the ones in the transaction, but all of them)
Replace the "HAS_CURRENT_INVENTORY" relationship to the inventory nodes affected, and give them an "archived" relationship. Simultaneously, create "HAS_CURRENT_INVENTORY" links to the new inventory nodes.
Is there a more optimal way to implement this? It is important to have a snapshot of inventory levels across the event when a single transaction occurred, or at an arbitrary point in time. However, I am creating a tonne of stuff for each transaction at the event. Is there a better way to query the info?
Related
I am trying to make small POS system, using FDMem table to fill items for the customer.
In case the customer forget his money or go to change a product .. and the customers in the line move and new customer shows up asking to start sale process, how can I save or freeze the current state of the FDMem table holding the products of the previous customer and start a new order and finish the sale. Then, when the first customer comes back, how can I resume the previous sales process and reactivate the previous FDMem table with it's items?
Add one more column in the FDMem table. That column could take 3 values: 'Finalized', 'Opened' and 'Paused' depending how the "status" of the sales is going. You can then navigate between the records.
So if I understand you correctly you want to be able to handle multiple customers or orders at the same time.
One solution one would guess would be to assign each customer unique number and them add that number as additional field to each record in your database. Now assigning unique values to online customers isn't particularly difficult. In fact you already have such information in form of session ID. But doing something like this for customers in a physical store is not feasible.
But there is another similar solution. Most Tax authorities require any shops to issue a receipt for any purchase made. And each of those receipts needs to have a unique number. So you could reserve a new receipt number when customer gets to your POS for the first time and you start adding its items to the system. Then you might want to have another table with all reserved receipt numbers and their current status, so you can know which receipt has been finished which one is still pending completion or which one was cancelled.
I have the following 2 existing nodes in my graph.
A Customer node identified by a unique customer number.
A Product node identified by a unique ISBN identifier.
I want to create an association between one Customer node and one Product node.
But I want to represent this association as a new node called a License node which will have one link to the Customer node and one link to the Product node.
This License node will have a new internal identifier generated as a random GUID.
My logic in my application which creates the new License node and links them to the other 2 nodes is executed in one transaction.
if (Product NOT already associated with the License for that Customer)
create a new License node with a new random GUID
create a relationship from the new License Node to the Product Node
create a relationship from the Customer Node to the new License Node
However multiple requests can arrive at the same time with the same ISBN and customer number.
When this happens I am sometimes getting duplicate License nodes created for the same Customer and Product nodes.
The transaction in spring data neo4j does not seem to prevent this from happening.
Example of correctly added License
Example of License added twice
How can I ensure that only one License node will get created between the Customer node and the Product node?
The transaction in spring data neo4j does not seem to prevent this from happening.
Neo4j has read commited isolation level for transactions. To prevent this you would need serializable.
To achieve what you need you could:
lock Product and Customer node before doing the Product NOT already associated with... check. You could use a query like this to do that (within the same transaction):
MATCH (n:Product) WHERE ID(n) = {id} REMOVE n._lock
and similar for Customer.
add a special key to License which is a concatenation of Product and Customer ids - then create a unique constraint on that.
I have to track the status of my business process for analysis purpose. I have seen a post where it is mentioned that we can keep the status in Transaction Fact Table against time/transaction type/service center and we can use the Accumulated fact table to study the process lag, I am wondering if few transactions have multiple status in a single day should I store all the status in Transaction Fact Table? Here I am assuming that my ETL is done at end of the business day.
Secondly should i keep all my key dimensions keys into Transaction Fact Table. Keys in this case are Transaction Type, Department id, Service_type, Service_id, Submission Channel or should I divide them in multiple fact tables?
Third if I need to report which department is meeting its SLA what would be the best approach, Calculate and keep track of Within SLA and Not Within SLA in Transaction Fact Table or I should compute this value at run time?
Thanks in advance for your help and assistance.
For status tracking you should have:
A transaction table where ony events show up (but does not provide event tracing)
An accumulating snapshot table where each process's status are tracked/updated as they happen.
As for the keys, you should keep as much detail as possible. No need to delete keys if they may hold valuable information in the future.
I'm trying out recommendation system(academic exercise) for a specific use case where users and items are one to many associated. Say at a given time a particular item can be owned by only one user. User can own multiple items at a time. Any particular item has many similar items which might interest the owning user. I want to find an item and recommend it to user. Usually in user based recommendation, entities will be of many to many association. If user U1 owns items I1,I2,I3 and user U2 owns items I1,I2,I3,I4 we would recommend I4 to U1. In my case one item can be owned by only one user at a given time. How to perform recommendation in this case. Is it possible to perform user based recommendation?
One possible option is always to conert one problem to another. Given one-to-many information, you can for each item X (knowing some kind of similarity measure, which is required here, without it you cannot do any recomendation) you create an object "items similar to X to some extent" call it C[X], and once you go through all items -- you get new kind of data. You have users, and "items clusters" C. Now you can assume that user A "likes" cluster C[X] iff user A likes any item from C[X]. This way you have many-to-many relation on the same data, with a bit of "smoothing". Now you can use any kind of existing system, and once you get the recommendation C[Y] you "recommend" any free (avaliable) item from C[Y].
How do you store facts within which data is related? And how do you configure the measure? For example, I have a data warehouse that tracks the lifecycle of an order, which changes states - ordered, to shipped, to refunded. And for a state like 'refunded', it is not always there. So in my model, I am employing the transaction store model, so every time the order changes state, it is another row in the fact table. So, for an order that was placed in april, and refunded in may, there will be two rows - one with a state of 'ordered' and another with a state of 'refunded'. So if the user wanted to see all the orders placed/ordered in april, and wanted to see how many of 'those' orders got refunded, how would he see that? Is this a MDX query that will be run at runtime? Is this is a calculated measure I can store in the cube? How would I do that? My thought process is that it should be a fact that the user can use in a pivottable, but I'm not sure.....
One way to model this would be to create a factless fact table to model events. Your ORDERS fact table models the transaction amount, customer information etc, while the factless fact table (perhaps called ORDER_STATUS) models any events that occur in relation to a specific order.
With this model, it's easy to count or add all transactions based on their order status by checking for existence of records in the factless fact table.