I have a graph such as
A-->B-->C-->D
|-->E-->F
|-->G
|-->H
How can I duplicate it from B, keeping properties and relationships(include relationship types), and append it to A, so it would look like
A-->B-->C-->D
| |-->E-->F
| |-->G
| |-->H
|
|-->B2-->C2-->D2
|--->E2-->F2
|--->G2
|--->H2
The purpose is to provide a "staging" version of the entity (A), that can be edited without affecting the one being shown - B and B2 has a version property by which they can be ordered. The changes made to B must be saved continuously while one is working on it, and until the changes are either cancelled or commited. After a commit is made on the staging version, the new one (B2) will be given B.version+1 as version.
edit: The 3rd and 4th columns in the example are not fixed, B can have any amount of nodes connected to it, and so can those.
Related
I have a csv file in my ADLS:
a,A,b
1,1,1
2,2,2
3,3,3
When I load this data into a delimited text Dataset in ADF with first row as header the data preview seems correct (see picture below). The schema has the names a, A and b for columns.
However, now I want to use this dataset in Mapping Data Flow and here does the Data Preview mode break. The second column name (A) is seen as duplicate and no preview can be loaded.
All other functionality in Data Flow keeps on working fine, it is only the Data Preview tab that gives an error. All consequent transformation nodes also gives this error in the Data Preview.
Moreover, if the data contains two "exact" same column names (e.g. a, a, b), then the Dataset recognizes the columns as duplicates and puts a "1" and "2" after each name. It is only when they are case-sensitive unequal and case-insensitive equal that the Dataset doesn't get an error and Data Flow does.
Is this a known error? Is it possible to change a specific column name in the dataset before loading into Data Flow? Or is there just something I'am missing?
I testes it and get the error in source Data Preview:
I ask Azure support for help and they are testing now. Please wait my update.
Update:
I sent Azure Support the test.csv file. They tested and replied me. If you insist to use " first row as header", Data Factory can not solve the error. The solution is that re-edit the csv file. Even in Azure SQL database, it doesn't support we create a table with same column name. Column names are case-insensitive.
For example, this code is not supported:
Here's the full email message:
Hi Leon,
Good morning! Thanks for your information.
I have tested the sample file you share with me and reproduce the issue. The data preview is alright by default when I connect to your sample file.
But I noticed when we do the trouble shooting session – a, A, b are column name, so you have checked the first row as header your source connection. Please confirm it’s alright and you want to use a, A, b as column headers. If so, it should be a error because there’s no text- transform for “A” in schema.
Hope you can understand the column name doesn’t influence the data transform and it’s okay to change it to make sure no errors block the data flow.
There’re two tips for you to remove block, one is change the column name from your source csv directly or you can click the import schema button ( in the blow screen shot) in schema tab, and you can choose a sample file to redefine the schema which also allows you to change column name.
Hope this helps.
For some reason when executing $bean->relation->getBeans() inside before_relationship_add hook it shows old AND new relationship.
I just want to see the relationships that were there BEFORE..
I tried to extract it from $bean and $arguments, but can't seem to find it
We can see what new record was added by checking $arguments['related_module'] and $arguments['related_id'].
So if we can identify what is the new record, we can determine what the old records were there prior to relationship add..
Example: we have 3 records with IDs 1,2 and 3 and the latest ID that was added is 3 ($arguments['related_id']), that means that IDs 1 and 2 were there before relationship was added.
This is kind of backwards and was hoping that before_relationship_ad
Technically speaking we can even do this in the after_relationship_add hook
I'm trying to build a database (in PostgreSQL 9.6.6) that allows for one "master column" (items.id) to be replicated in to many (automatically generated) tables (e.g. rank1.id, rank2.id, rank3.id, ...). Only items will have INSERT's (or DELETE's) performed and when they are the newly added id's should also show up (or be removed) in the rankX table(s). To be more concrete:
items:
id | name | description
rank1:
id | rank
rank2:
id | rank
...
Where the id's are always the same, and there is always the same number of rows in each of the tables. The rankX.rank values, however, will be different (imagine users ranking how funny a series of images are -- the images all have the same id's but different users might rank them differently).
What I was thinking was that when a new user was added and a new rankX table created I would do the following:
Have rankX.id referencing a foreign key items.id (with ON DELETE CASCADE)
Copy any items.id that already exist
Auto-generate a trigger function that mirrors the INSERT's to items to the rankX table
This seems cumbersome and wasteful of space since all of the xxxx.id columns are identical and I will end up with hundreds or thousands of trigger functions. As someone new to relational databases I was hoping there was an easier way to achieve this.
So, I have a few questions:
Is there a more efficient way to define my tables such that all of this copying isn't necessary?
If this the best way, can you give an example of how you would set up the triggers (and associated functions)?
Do I need to worry about running out of space on the server as I create (potentially many) sets of triggers of this type?
We have a people table, each person has a gender defined by a gender_id to a genders table,
| people |
|-----------|
| id |
| name |
| gender_id |
| genders |
|---------|
| id |
| name |
Now, we want to allow people to create forms by themselves using a nice form builder. One of the elements we want to add is a select list with user defined options,
| lists |
|-------|
| id |
| name |
| list_options |
|--------------|
| id |
| list_id |
| label |
| value |
However, they can't use the genders as a dropdown list because it's in a different table. They could create a new list with the same options as genders but this isn't very nice and if a new gender is added they'd need to add it in multiple places.
So we want to move the gender options into a list that the user can edit at will and will be reflected when a new person is created too.
What's the best way to move the genders into a list and list_options while still having a gender_id (or similar) column in the people table? Thoughts I've had so far include;
Create a 'magic' list with a known id and always assume that this contains the gender options.
Not a great fan of this because it sounds like using 'magic' numbers. The code will need some kind of 'map' between system level select boxes and what they mean
Instead of having a 'magic' list, move it out into an option that the user can choose so they have a choice which list contains the genders.
This isn't really much different, but the ID wouldn't be hardcoded. It would require more work looking through DB tables though
Have some kind of column(s) on the lists table that would mark it as pulling its options from another table.
Would likely require a lot more (and more complex) code to make this work.
Some kind of polymorphic table that I'm not sure how would work but I've just thought about and wanted to write down before I forget.
No idea how this would work because I've only just had the idea
The easiest solution would change your list_options table to a view. If you have multiple tables you need have a list drop down for to pull from this table, just UNION result sets together.
SELECT
(your list id here) -- make this a part primary key
id, -- and this a part primary key
Name,
FROM dbo.Genders
UNION
SELECT
(your list id here) -- make this a part primary key
id, -- and this a part primary key
Name,
FROM dbo.SomeOtherTable
This way it's automatically updated anytime the data changes. Now you are going to want to test this, as if this gets big it might get slow, you can get around this by only pulling all this information once in your application (or say cache it for 30 minutes and then refresh just in case).
Your second option is to create a table list_options and then create a procedure (etc.) which goes through all the other lookup tables and pulls the information to compile it. This will be faster for application performance, but it will require you to keep it all in sync. The easiest way to handle this one is to create a series of triggers which will rebuild portions (or the entire) list_options table when something in the look up tables is changed. In this one, I would suggest moving away from creating a automatically generated primary key and move to a composite key, like I mentioned with the views. Since this is going to be rebuilt, the id will change, so it's best to not having anything think that value is at all stable. With the composite (list_id,lookup_Id) it should always be the same no matter how many times that row is inserted into the table.
I'm having an issue with the Microsoft Sync Framework 2.1 and I'm hitting a stumbling block. To simplify lets say I'm syncing two tables, ConfigSet and ConfigItem, which have the following structure:
|ConfigSet |
|-----------------|
|ConfigSetID (PK) |
|ConfigItemID (FK)|
|ConfigItem |
|-----------------|
|ConfigItemID (PK)|
|ConfigItem.Data |
I'm using a filtering clause for both that's driven by ConfigSetID:
ProvisionerObject.Tables["ConfigSet"].FilterParameters.Add(new SqlParameter("#ConfigSetID", SqlDbType.UniqueIdentifier));
ProvisionerObject.Tables["ConfigSet"].FilterClause = "[side].[ConfigSetID] = #ConfigSetID"
ProvisionerObject.Tables["ConfigItem"].FilterParameters.Add(new SqlParameter("#ConfigSetID", SqlDbType.UniqueIdentifier));
ProvisionerObject.Tables["ConfigItem"].FilterClause = "[side].[ConfigItemID] in (SELECT ConfigSet.ConfigItemID FROM ConfigSet WHERE ConfigSet.ConfigSetID = #ConfigSetID)"
If I then create two ConfigItem records on the server side, 'Item1' & 'Item2', and create one ConfigSet record, 'Set1', that has a foreign key to to 'Item1', and then perform a sync it will work fine and the client will get the 'Set1' record and only 'Item1' from ConfigItem.
If I then perform an update on 'Set1' on the server so that it now points to 'Item2', the sync framework detects the changes in ConfigSet but then throws a foreign key constraint on the client saying the record 'Item2' doesn't exist.
It appears that when syncing ConfigItem that it isn't detecting any changes, because technically there have been none to ConfigItem, but the filter clause would return Item2 had this been syncing for the first time.
I understand that each table is synchronised independently, but is there a way I can force it to pick up the 'Item2' record even though there are no changes to that table? And even better (although I think I'm pushing my luck on this one with what the framework can do!) would be if it could remove 'Item1' on the client since this is technically no longer synchronised/referenced by the client.
unfortunately, sync framework doesnt support partition realignment or rows going in and out of scope.
the simpliest workaround in your scenario is to do a dummy update on item2 to mark it as changed. however, this means this change will also be sent to the other clients having item2, wasted transaction since nothing has really changed.
as for rows in the client that has gone out of scope, you can delete them from client and intercept the changes in the ChangesSelected event and remove the rows from the change dataset so they dont propagate up to the server. or you can simply, clean up the client table and reinitialize based on the new filter value.