How can I group many values for a variable in grafana? - grafana

I have an SQL table with columns: name and user type.
Name
type
John
student
Tom
teacher
Peter
teacher
Steve
student
I want to have a grafana variable where I can select a user "type" and the variable passes the value of all the "names" corresponding to that "type" to the dashboard.
I found this example - https://grafana.com/blog/2019/07/17/ask-us-anything-how-to-alias-dashboard-variables-in-grafana-in-sql/ which lets me alias a one to one mapping, but I am looking for a one to many mapping.

Related

Get Lookup value in WSS_Content

I try to find where does Sharepoint 2016 store lookup values in database.
I create Person and Gender lists:
I wonder a relation from Gender and Person lists. How Person list can get exactly gender data from Gender list. Could anybody provide me the SQL query to get data.
many thanks

Microsoft Master Data Services 2016 Additonal Domain Atrribute Referencing

Is it possible to reference additional columns apart from the 'Code' and 'Name' columns when using a domain attribute in an entity?
E.g. A person entity has a code of '1' and a name of 'Smith' and a Gender of 'Male'
In a customer entity there is a domain value referencing the person entity which displays the following 1 {Smith}. The users would like an additional read only attribute which would copy the Gender value of 'Male' into the customer entity based on the domain value. Can this be done using out of the box MDS UI?
I know this is duplicate data and breaks normal form but for usability this would be useful. It would be the equivalent of referencing additional columns in an MS Access drop down list.
Many thanks in advance for any help
This is not possible with the standard UI. One option would be to develop a custom UI where you can handle these kind of requests.
If you want to stick with the standard product I can see a workaround but this is a bit of a "dirty" one.
You can misuse (abuse) the Name attribute of the Person entity by adding a business rule to the Person entity that generates the content of the Name attribute as a concatenation of multiple attributes. You of course need an additional attribute that serves as a place holder for the original Name. The concatenated field will then show in your customer entity.
One question that does come to mind is why a user would like/need to see the gender of a person in a customer list? As you have a separate Person entity I expect you to have multiple persons per customers. What would the gender of one person - even if it is the main contact - matter?

MongoDb conditional relationship

Suppose I have following 4 collections:
1- posts
2- companies
3- groups
4- users
Bellow is my current structure in post:
and their relation is:
A company has an owner and many other members (user collection).
A group has many members (users).
A user has many posts.
A group has many posts that published by one of its members.
A company has many posts that published by its owner or members.
Now i have a problem on storing relation of users, company, and group with posts collection.
Bellow is my current structure:
I have decided to have a field postable inside my post document, and has a type field that will be 'user', or 'group', or 'company', and two other fields name, and id that will be company/group id and company/group name in cases that post is belonged to company or group but not user means type="group" || type="company".
Now how i can handle this to map id as FK of group and company collection (one field FK of two collection) ?
Is it the right structure ?
What you have here is a polymorphic association. In relational databases, it is commonly implemented with two fields, postable_id and postable_type. The type column defines which table to query and id column determines the record.
You can do the same in mongodb (in fact, that is what you came up with, minus the naming convention). But mongodb has a special field type precisely for this type of situations: DBRef. Basically, it's an upgraded id field. It carries not only the id, but also collection name (and database name).
how i can handle this to map id as FK of group and company collection (one field FK of two collection)?
Considering that mongodb doesn't have joins and you have to load all references manually, I don't see how this is any different from a regular FK field. Just the collection name is stored in the type field now, instead of being hardcoded.

Retrieve the data from the relationship in parse DB through Rest API

I am been going through the parse DB but got stuck at one issue. The issue is How can I retrieve the data from the relationship in parse DB.
For ex: I have two table
Department
Employee
Department table structure is:
ObjectId
departmentId
deparmentName
Employee table structure is:
ObjectId
EmployeeName
Age
department
In the Employee table i have created one column with department and added the relation With Department table.
I have successfully added the records and created a relation. And when i am clicking on View Relation in department column i am getting the data for the associated Department.
I have given the curl command to get the data:
Curl -X GET <my application Id> <my rest api key>
https://api.parse.com/1/classes/Employee
I am getting the result as
{"results":[{"department":{"__type":"Relation","className":"Department"},"createdAt":"2015-08-07T08:53:23.220Z","objectId":"AkceV0fwW","updatedAt":"2015-08-07T09:04:45.362Z","userName":"XYZ"}]}
Now how to retrieve the objectId of the Department in this result means I want to get the department name for this Employee.
Department class doesn't have an objectId, instances of that class do, and your statement means you're thinking about the relationship query backwards.
The relation holds multiple instances (potentially). If you just want one then you should use a pointer as it's much easier.
With a relation you use the objectId of the container and the name of the relation to do a query on the contained class:
GET https://api.parse.com/1/classes/Department
'where={"$relatedTo":{"object":{"__type":"Pointer","className":"Employee","objectId":"AkceV0fwW"},"key":"department"}}'

Advanced Queries in EF Code First

I have a main table for gather Real Estate records. This table has relations with other reference data tables, so in summary it contains IDs for:
CountryId
TypeId
PurposeId
CurrencyId
etc...
There are other tables like Countries, Types, Purposes, etc ...
When creating a new Real Estate record, based on the "Type", there are some "Extended Properties" defined. So user has to enter values for those "Extended Properties" that are directly linked to the selected "Type".
An example of Extended Property something as:
Bedrooms
This property might have 1 or more values like:
1
2
3
I am storing a table of Extended Properties and another for Extended Property Values, as one Property might have one or more values.
For a given Type, there might be one or more such properties, hence I had to define a new table to link:
RealEstate ID
ExtendedProperty ID
ExtendedProperty Value ID
Now, the website offers a search engine, user can enter search criteria for the following fields:
Country
Type
Purpose
One or more Extended Property (based on the Type selected and its related Properties)
I need to query the DB and return full data records, i.e. When I return a Real Estate record, I need to return the TypeID + TypeName and CountryID + CountryName, etc ... In other words, I need to join all those tables and then query with the values I received from the search criteria, and such a criteria can be something as:
CountryId = 1
Type = 2
EP (1,5) (Find me a Real Estate record that has an Extended Property whose ID is "1" and has a value for that property equal to Extended Property Value ID of "5".
etc ...
I believe, all other tables, its a matter of normal join and checking on some parameters, but its gets harder when I have to query the Extended Properties.
Much appreciated.