I'm designing the schema for a graph database and couldn't find anything about pros and cons of how to name edges. My edges will have a minimum of two descriptors (label and property, or two properties) that describe the correct tree for a given root vertex.
here's my test graph:
// probably not efficient, but is an attempt at preventing duplicate vertices before introducing an index
g.V().has('person', 'name', 'annie').fold().coalesce(unfold(), addV('person').property('name', 'annie'))
g.V().has('person', 'name', 'bernie').fold().coalesce(unfold(), addV('person').property('name', 'bernie'))
g.V().has('person', 'name', 'charlie').fold().coalesce(unfold(), addV('person').property('name', 'charlie'))
g.V().has('person', 'name', 'danielle').fold().coalesce(unfold(), addV('person').property('name', 'danielle'))
g.V().has('person', 'name', 'edward').fold().coalesce(unfold(), addV('person').property('name', 'edward'))
g.V().has('person', 'name', 'frank').fold().coalesce(unfold(), addV('person').property('name', 'frank'))
g.V().has('person', 'name', 'gisele').fold().coalesce(unfold(), addV('person').property('name', 'gisele'))
// 1983
annie = g.V().has('person', 'name', 'annie').next()
bernie = g.V().has('person', 'name', 'bernie').next()
g.addE('manages').property('org', 'finance').property('during', 1983).from(annie).to(bernie)
// 1984
charlie = g.V().has('person', 'name', 'charlie').next()
g.addE('manages').property('org', 'finance').property('during', 1984).from(annie).to(bernie)
g.addE('manages').property('org', 'finance').property('during', 1984).from(annie).to(charlie)
// 1985
danielle = g.V().has('person', 'name', 'danielle').next()
edward = g.V().has('person', 'name', 'edward').next()
g.addE('manages').property('org', 'finance').property('during', 1985).from(annie).to(bernie)
g.addE('manages').property('org', 'finance').property('during', 1985).from(annie).to(edward)
g.addE('manages').property('org', 'finance').property('during', 1985).from(annie).to(charlie)
g.addE('manages').property('org', 'finance').property('during', 1985).from(bernie).to(danielle)
// new org
frank = g.V().has('person', 'name', 'frank').next()
gisele = g.V().has('person', 'name', 'gisele').next()
g.addE('manages').property('org', 'engineering').property('during', 1985).from(frank).to(gisele)
g.addE('manages').property('org', 'engineering').property('during', 1985).from(frank).to(danielle)
g.addE('manages').property('org', 'engineering').property('during', 1985).from(frank).to(edward)
// frank is trying his hand at finance
g.addE('manages').property('org', 'finance').property('during', 1985).from(edward).to(frank)
In regards to the edge schema in this example, the label name (I don't think...) is very important. It's already inferred who manages who by the direction of the edge. I'm not sure if there will be more than one type of edge in this graph yet, just the hierarchy. So, would there be any advantage / disadvantage to just labeling the edges with the org name or "during" year? any performance differences?
The only advantage I see so far is visual differentiation in a tool like graphexp, where it only shows the edge label...
I'm running queries like this to get the correct tree:
g.V().has('person', 'name', 'annie').emit().
repeat(outE().and(has('during', 1985), has('org', 'finance')).inV()).
path().local(unfold().values('name').fold())
Label is analogy to TableName in RDBMS. There are two disadvantage to "just labeling the edges with the org name or 'during' year" I can address:
In your described case, there is only one edge type. If you wanna to add another edge type like 'friendship', it will be hard to diff these two edge types. Find 'manages' edges of one person may need to iterate all edge including 'friendship' and 'manages'.
Most graph database implementations, such as 'janusgraph', hold a mapping table from 'label' string to internal label id. If there are too many edge labels, it will introduce more execution cost, or may run out of internal label id.
Related
i trying to find some way to display/insert/update the information on the form where the information is dynamic. the extjs i currently using is Ext JS 7.1.x Classic
the schema are as below
name of item
cost price of the item
product code of the item
location ([latitude and longitude];rack number;shelves number)
remarks
For example the forms will have a list of location in the form for that item which i able to to add, delete and update each row of location?
data are as show below
PowerBank,10,MPB001,["000.1,111";2;2,"000.2,222";2;2,"000.1,111";1;2],My Power Bank
Earphone,4,MEP001,["000.1,111";2;3],My Earphone
i thinking of something like ListView or Datagrid?
For initial data, update data and insert you can use
form.setValues({
name: 'PowerBank',
cost: 10,
code: 'MPB001',
locationLatitude: '000.1',
locationLongitude: '111'
rack: 2,
shelves: 2,
remarks: 'My Power Bank'
});
Other than that you could use data-binding
data-binding
Let's say you have a grid and bind the selection:
xtype: 'grid',
bind: {selection: '{gridSelection}'}
And you have the selected dataset in your viewModel
data: {
gridSelection: null
}
Then you can add the data to the form like this:
items: {
xtype: 'textfield',
name: 'remarks',
bind: {value: '{gridSelection.remarks}'}
}
problem
you might run into a problem if you are trying to listen on the dirty states with data-binding. But you can solve this by making all fields not dirty after the data-binding triggers.
In the kitchen sink classic pivot grid configuration plugin example there are row numbers in the first column of the grid.
Does anyone know how to do this?
Here's the link to the example
https://examples.sencha.com/extjs/7.1.0/examples/kitchensink/?classic#configurable-pivot-grid
I tried setting rowNumbers to true but it didn't work
Thanks
rownumberer is column type. you must use it in columns
columns: [
{xtype: 'rownumberer'},
{text: "Company", flex: 1, sortable: true, dataIndex: 'company'},
]
Edited:
sorry for wrong answer. it was for ordinary grid. to show rowNumbeber on pivot grid set
selModel: {
type: 'spreadsheet'
},
Can someone help me to figure out a way to arrange the columns irrelevant of it columns array positioning? For example, in below grid columns array i just want to display Phone as 1st column and Name as 2nd column. How can i achieve that programmatically?
Columns Array:-
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email'
}, {
text: 'Phone',
dataIndex: 'phone'
}]
While debugging the grid column config with Chrome developer tools, i figured out a parameter "fullColumnIndex" which value getting increased for every column. But specifying that explicitly doesn't make any difference :(
Thanks!
You can do it by using reconfigure method. Docs — http://docs.sencha.com/extjs/5.1/5.1.0-apidocs/#!/api/Ext.panel.Table-method-reconfigure
Here is the description of this method:
reconfigure( [store], [columns] )
Reconfigures the grid / tree with a new store/columns. Either the store or the > columns can be omitted if you don't wish to change them.
The enableLocking config should be set to true before the reconfigure method is > executed if locked columns are intended to be used.
Parameters
store : Ext.data.Store (optional)
The new store. You can pass null if no new store.
columns : Object[] (optional)
An array of column configs
I have a tree that is loading asynchronously. I have two models, Manager and User.
Managers can be parent nodes or leaf nodes, but Users can only be leaf nodes. So, a Manager can have any number of Managers above or below him, but I User can only be the child of a Manager.
I have set up proxies for the User and Manager models and set Manager as the TreeStore's Model parameter. I tried using hasMany and belongsTo to describe the relations, hoping that every time I expand a node, a get for Users and for Managers is sent. It isn't working. I'm only getting Managers, not Users.
Anyone have any tips for working with these kinds of relationships?
Create new model 'Employee' that will have a property (IsUser) and load into list both managers and users IE:
Ext.regModel('Employee', {
fields: [
{ name: 'ID', type: 'int' },
{ name: 'Name', type: 'string' },
{ name: 'LastName', type: 'string' },
//....
{ name: 'IsUser', type: 'int' }
]
});
And SQL query for populating should look like this:
SELECT id, name, lastname, 0 as IsUser
FROM managers ...
UNION
SELECT id, name, lastname, 1 as IsUser
FROM users ...
I have a grid Panel with 4 columns, one of these is numeric (number up to 4 digit), and I would like to sort the row by this colum. My problem is Ext JS sorts the rows as if the column was textual, so 5 is sorted after 3000.
I tried to use a numberColumn instead of a normal column (specifying the x-type in the columns of the GridPanel), but it doesn't change the sorting.
Thus I tried to format the numbers so 5 would appear like 0005, and 0005 would be before 3000. But the format options of the numberColumn do not appear to let me specify a minimal number of digit (in Java, using NumberFormat, 0000 would work, but here it doesn't).
So I put a renderer to force my number to appear with 4 digits, it works, but it seems that the sort method use the values before beeing rendered, wich is quite logical.
I'm stuck after trying all my ideas, does anyone have a clue?
If you're using a remote store sort, then the sorting is done remotely (the database, like mysql). So what is the type of column on the database for that field? If it's a char or varchar, then that's the issue.
I've had a similar issue, the column type doesn't fix this. To have a proper ordering the type in model should be numeric.
1) Set your field type as integer in model definition.
Ext.define('myModel', {
extend: 'Ext.data.Model',
fields: [{ name: 'myField', type: 'int' }]
});
2) Create a Store using that model.
var myStore = Ext.create('Ext.data.Store',{
model: 'myModel'
});
3) Define a GridPanel using the store and link your field as dataIndex into columns definition.
Ext.create('Ext.grid.Panel',{
store: myStore,
columns: [{
header: 'Numbers', dataIndex: 'myField'
}]
});
I encountered a similar problem where by exj grids sort by each digit in your number, so for example a list might be reordered to 1, 2, 22, 3, 4, 41, 5... for what its worth, i found in extjs4, that defining the type as int in the model did the trick, I havent specified the local or remote sort but it seems to be working...
Ext.define('ExtMVC.model.Contato', {
extend: 'Ext.data.Model',
fields: [{'id', type: 'int'}, 'name', 'phone', 'email']
});
This is my code that connects to a MySQL. I followed this -> {'id', type: 'int'}, and it work out fine... Thank you all! I'm using Ext js 4.2.x