One-to-One Relationship on ERD - erd

I have a scenario which I have to model using an ERD, but having difficulty with a few things...
So the one-to-one scenario is as follows:
A single SMS message has a single piece of Message Metadata.
A single piece Message Metadata is associated with only a single SMS Message.
The message basically contains the data regarding the state of certain components on a switch board.
In Metadata table, is Primary Key needed?
How would the posting happen? Would 'MessageID' (from the SMS Message table) be used as foreign key in Message Metadata table?
Table definitions below:
SMS Message: MessageID (pk), UserID (fk), SwitchState (bit),
MotorState (bit), Priority (int)
Message Metadata: SIM Number (bigint), NameOfSender (varchar), Time
(time), Date (date)

I understood that you get a one-one relatiion between sms and metadata.
In the DB, you should get one table only. You should get a Pk for message and that's should be enought.
In JEE, you should use #Embeddable and #Embedded annotations.
There is no way to model that in UML, you can use annotations linked to your class or define a stereotype but if you want to follow the spectification strictly, that's not an easy task.

Related

Should rest apis return a message for an enum besides its value?

Say, we have an api which returns a list of employee records. Each record has a gender field whose value may be 'MALE' or 'FEMALE'. We want to show the gender of each employee with a message which may be 'Male' or 'Female'.
To achieve the goal above, we have following options:
Return both the value and the message so the client doesn't bother
Return the value only and let client determine the appropriate message
Which one is better?
It does depend. If you plan to give a uniform vision about your backend data and potentially there will be N API Consumer that will use your service, I'd prefer the first option. This can come in handy if you have to tackle to internationalization issue

How to extract the synonym values from an entity in Watson Conversation

I need to extract all the synonym values for a particular entity. For example, I have an entity named Vehicle with values Car and Bus. For Car I have three synonyms, Mercedes,Volvo and Audi. Now what I need is when the entity Vehicle is detected in the user input for a value Car, I want to extract all the three synonym values present for Car. I know #Vehicle.literal will return the exact synonym value detected in the user input. But how can I retrieve all the synonyms for a particular entity value?
You can use the Conversation API to get information on an entity and its metadata. That information is not available in a dialog context itself.
IMHO a better way would be to use a database or similar to match up the detected entity with a list of synonyms. Usually, Conversation service is not used on its own, but part of a solution. The app server could perform the lookup if flagged. Take a look at the dialog actions for that. Or this suggestion on using the method of replaced markers in an answer.
Basically you can not extract the synonyms.One thing yiu can do is to create another entity with values as your car names and synonyms as vehicle.So that whenever a vehicle is input it will give you all the entity values.

How to store only node specific off-ledger custom data in corda?

I created custom table in corda using QueryableState. e.g. IOUStates table.
I can able to see the custom information getting stored in this kind of table.
but i observed that if party A and Party B is doing the transaction then this
custom information gets stored at both the places , e.g. IOUStates
table getting created at nodeA ledger as well as nodeB's ledger.
and custom information is stored in partyA's and PartyB's ledger.
My Question is :-
If some Transaction is getting processed from PartyA's node , then
I want to store part of the transaction's data i.e. custom data ONLY at partyA's Ledger.* level . i.e. off-Ledger of partA only.
It should not be shared with partyB.
In simple case , how to store Only node specific off ledger custom data ?
Awaiting for some reply...
Thanks.
There's a number of ways to achieve this:
Don't use Corda at all! If the data is truly off-ledger then why are you using Corda? Instead, store it in a separate database. Of course you can "JOIN" it with on-ledger data if required, as the on-ledger data is stored in a SQL database.
Similar to point one except you can use the jdbcSession() functionality of the ServiceHub to create a custom table in the node's database. This table can easily be accessed from within your flows.
Create a ContractState object that only has one participant: the node that wants to store the data. I call this a "unilateral" state, i.e. a state that only one party ever stores.
Most importantly, if you don't want to share some data with a counter-party then it should never be disclosed inside a corda state object or attachment that another party might see. Instead:
inside your flows, you can use the data encapsulated within the shared state object (e.g. the IOU) to derive the private data
alternatively if the data is supplied when the flow begins then store the private data locally using one of the methods above

SQLite | WebSQL - Grouped double ordering? That sounds wrong

I have no idea what to call what I'm trying to do, but I can explain it quite well. I have two tables with the following structure in my WebSQL database. This is being used in my mobile application (Hybrid app) to keep storage of user messages. These are my tables:
message_threads [ thread_id, user_id, last_seen, last_active ]
messages [ message_id, thread_id, message_type, message_content, message_date ]
I already have all of the logic handled for adding messages to the database, and creating new message threads, but the problem I have is ordering them when trying to retrieve them.
I would like to order my results (of messages) by the last_active field of the message_thread with the corresponding thread_id. However, now that I've done that, I also want to order all of the messages for that thread by the message's message_date field.
So, basically, I want to group all of my messages by their thread, order the thread by the last_active field, then order the messages inside of that thread by the message_date field. I assume there's a way to do this in SQLite, and if not I can just do a lot of loop logic on the front-end, which really won't hurt anything, but it's always nice to know the tricks of the query language.

How to create a new record with a particular GUID

Using the Dynamics CRM I'm trying to create an instance of an entity. I would like to manually set the GUID, but if I had the attribute that is the primary key to the DynamicEntity, I get following error.
Service could not process request
I am building a DynamicEntity, and setting the [entityname]id attribute causes the request to fail. It's moving data between two CRM instances, so if anyone knows of a better way to copy records between CRMs, that'd work too. Otherwise, I'd like the GUID to match across instances... as that's the point of a GUID.
Happily, it IS possible to do this across two CRM instances! A co-worker knew the solution, so credit really belongs to him.
My mistake was creating a Property with type UniqueIdentifierProperty. The primary key attribute on an entity needs to be filled in with a KeyProperty. These two properties are nearly identical -- the Property types are, except that one holds a Key, the other a UniqueIdentifier. The Key/UniqueIdentifier both hold GUIDs. (Another day in the mind of Microsoft!)
Precisely, what I'm doing is creating a DynamicEntity, filling in the entity name, and filling in the majority of the attributes. The PK attribute (which you can determine from the metadata) can be filled in with a KeyProperty. I was filling it in with a UniqueIdentifierProperty, which CRM rejects and responds with a nondescript and unhelpful error message.
I apologize if I am over-simplifying the solution, but why not add a custom field in both instances that would be a mirror of the other instances guid?

Resources