Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am unsure if I am creating a proper schema for a CouchBase mobile database. Here is an example of a schema for 1 user's mobile app:
{
"users": [
{
"firstname": "Jim",
"lastname": "terry",
"addresses": [
{
"address": "123 Way",
"zipcode": "65432"
},
...
],
"activities": [
{
"steps": 500
},
{
"sleep_hours": 2
},
...
],
"posts": [
{
"subject": "Hello",
"body": "World"
},
...
]
},
...
]
}
A mobile app could have 1 to many users on a device. The server database could hold many users that the app would only have access to. What I am having a hard time wrapping my head around is whether this is a good data model for a couchbase app. I have denormalized all of the data associated to a user under a user schema. My questions are as follows:
What happens if activity gets really large for a user and posts gets really large? When you make an update to activity does it have to save the whole document which could create a performance option when only one piece of data on the user gets updated? Does the database break up these arrays as separate documents from the user?
Is it best practice to store the data in activities in this fashion? In the example, both objects are an activity but they contain completely separate data.
Is this the most efficient model? One example of a change might be instead of having a generic "activities":[] creating "step_activities" and "sleep_activities"?
Related
There is no dynamic content you can get from the SurveyMonkey trigger in Power Automate except for the Analyze URL, Created Date, and Link. Is it possible I could retrieve the data with an expression so I could add fields to SharePoint or send emails based on answers to questions?
For instance, here is some JSON data for a county multiple choice field, that I would like to know the county so I can have the email sent to the correct person:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
And basically, a way to create dynamic fields from the content so it would be more usable?
I am a novice so your answer will have to assume I know nothing!
Thanks for considering the question.
Overall, anything I have tried is unsuccessful!
I was able to get an answer on Microsoft Power Users support.
Put this data in compose action:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
Then these expressions in additional compose actions:
To get choice_id:
outputs('Compose')?['answers']?[0]?['choice_id']
To get simple_text:
outputs('Compose')?['answers']?[0]?['simple_text']
Reference link here where I retrieved the answer is here.
https://powerusers.microsoft.com/t5/General-Power-Automate/How-to-write-an-expression-to-retrieve-answer/m-p/1960784#M114215
Let's say I have a CLI which talks to a banking server to create a bank account. A bank account has a few properties, and a list of users associated with the account. If the bank account is represented as a json, it'll be
{
"accountType": "Savings",
"Balance": 500,
"Users": [
{
"firstName": "tony",
"lastName": "stark",
"nickName": "ironman"
},
{
"firstName": "Peter",
"lastName": "Parker",
"nickName": "spiderman"
}
]
}
I want to create this account object using a CLI, and I want to pass all the users at create time. Like
bank-cli account create --acount-type Savings --balance 500 <And the users>
How do I go about adding the users in the CLI? Adding the values like --firstName1 --lastName1 --firstName2 --lastName2 does not seem like a good UX. My current implementation is that this CLI opens up another editor, which accepts multiple lines of these parameters as
--firstName tony --lastName stark --nickname ironman
--firstName peter --lastName parker --nickname spiderman
And this is converted to an array of objects in the code. Is there a better way to do this?
I have considered accepting the parameters as json/toml or other formats. They didn't look too clean.
I have 1 million users in a Postgres table. It has around 15 columns which are of the different datatype (like integer, array of string, string). Currently using normal SQL query to filter the data as per my requirement.
I also have an "N" number of projects (max 5 projects) under each user. I have indexed these projects in the elasticsearch and doing the fuzzy search. Currently, for each project (text file) I have a created a document in the elasticsearch.
Both the systems are working fine.
Now my need is to query the data on both the systems. Ex: I want all the records which have the keyword java (on elasticsearch) and with experience of more than 10 years (available in Postgres).
Since the user's count will be increasing drastically, I have moved all the Postgres data into the elasticsearch.
There is a chance of applying filters only on the fields related to the user (except project related fields).
Now I need to created nest projects for the corresponding users. I tried parent-child types and didn't work for me.
Could anyone help me with the following things?
What will be the correct way of indexing projects associated with the users?
Since each project document has a field called category, is it possible to get the matched category name in the response?
Are there any other better way to implement this?
By your description, we can tell that the "base document" is all based on users.
Now, regarding your questions:
Based on what I said before, you can add all the projects associated to each user as an array. Like this:
{
"user_name": "John W.",
..., #More information from this user
"projects": [
{
"project_name": "project_1",
"role": "Dev",
"category": "Business Intelligence",
},
{
"project_name": "project_3",
"role": "QA",
"category": "Machine Learning",
}
]
},
{
"user_name": "Diana K.",
..., #More information from this user
"projects": [
{
"project_name": "project_1"
"role": "Project Leader",
"category": "Business Intelligence",
},
{
"project_name": "project_4",
"role": "DataBase Manager",
"category": "Mobile Devices",
},
{
"project_name": "project_5",
"role": "Project Manager",
"category": "Web services",
}
]
}
This structure is with the goal of adding all the info of the user to each document, doesn't matter if the info is repeated. Doing this will allow you to bring back, for example, all the users that work in a specific project with queries like this:
{
"query":{
"match": {
"projects.name": "project_1"
}
}
}
Yes. Like the query above, you can match all the projects by their "category" field. However, keep in mind that since your base document is merely related to users, it will bring back the whole user's document.
For that case, you might want to use the Terms aggregation, which will bring you the unique values of certain fields. This can be "combined" with a query. Like this:
{
"query":{
"match": {
"projects.category": "Mobile Devices"
}
}
},
"size", 0 #Set this to 0 since you want to focus on the aggregation's result.
{
"aggs" : {
"unique_projects_names" : {
"terms" : { "field" : "projects.name" }
}
}
}
That last query will bring back, in the aggregation fields, all the unique projects' name with the category "Mobile Devices".
You can create a new index where you'll store all the information related to your projects. However, the relationships betwen users and projects won't be easy to keep (remember that ES is NOT intended for being an structured or ER DB, like SQL) and the queries will become very complex, even if you decide to name both of your indices (users and projects) in a way you can call them with a wildcard.
EDIT: Additional, you can consider store all the info related to your projects in Postgress and do the call separately, first get the project ID (or name) from ES and then the project's info from Postgres (since I assume is maybe the info that is more likely not to change).
Hope this is helpful! :D
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am trying to parse an output from aws cli and pass it into another argument. I am trying to accomplish this with sed and am stuck on how to approach it, I have read other posts but can't seem to figure it out.
output:
{
"LoadBalancers": [
{
"Type": "network",
"Scheme": "internet-facing",
"IpAddressType": "ipv4",
"VpcId": "vpc-3ac0fb5f",
"AvailabilityZones": [
{
"LoadBalancerAddresses": [
{
"IpAddress": "35.161.207.171",
"AllocationId": "eipalloc-64d5890a"
}
],
"ZoneName": "us-west-2b",
"SubnetId": "subnet-5264e837"
}
],
"CreatedTime": "2017-10-15T22:41:25.657Z",
"CanonicalHostedZoneId": "Z2P70J7EXAMPLE",
"DNSName": "my-network-load-balancer-5d1b75f4f1cee11e.elb.us-west-2.amazonaws.com",
"LoadBalancerName": "my-network-load-balancer",
"State": {
"Code": "provisioning"
},
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e"
}
]
}
The string i am trying to capture is
arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e
and pass it into the following command:
aws elbv2 delete-load-balancer --load-balancer-arn <the arn extracted from the previous output>
If you provide a solution a small explanation would be helpful as well. Thanks in advance for your help!
If the output is json format, sed is not recommended to parse the json/xml...input.
You can use jq in shell, for your example, you can do:
..cmd to get yourOutput..|jq '.LoadBalancers[0].LoadBalancerArn'
In my application I want to use FHIR Questionnaire resource.
On the server side I am trying to generate questionnaire with different types of questions and send it to the application where user (patient) can fill in answers and send them back.
However in some cases I would like from user to answer only specific questions of the questionnaire and not all of them. For example if questionnaire consists of two questions:
Do you smoke or drink alcohol?
Measure your heart rate.
I would like that user answers second question only if he has answered on the first question with 'yes'. The second question is skipped if he has answered 'no'.
The problem is that I do not know how to add these rules, which will tell which question is next, inside the Questionnaire resource.
I came along to some extensions like ordinalValue, but I couldn't find out how/where to use them and where to define if user's answer must be equal / less / greater than some value.
So I would like to know which extension i need to use (and how) to achieve what I've written before? Is this even possible with existing extensions or I would have to define a new one?
I am adding simple representation (with only relevant data) of mentioned questionnaire in the JSON form:
{
"resourceType": "Questionnaire",
...
"item": [
{
"linkId": "1",
"text": "Do you smoke or drink alcohol?",
"type": "boolean"
<< ??? extension ???>>
},
{
"linkId": "2",
"text": "Measure your heart rate.",
"type": "integer"
}]
}
You could use the Questionnaire.item.enableWhen element for this:
{
"linkId": "2",
"text": "Measure your heart rate.",
"type": "integer"
"enableWhen": [{
"question": "1",
"answerBoolean": "true",
}
],
}