Skip to content

Instantly share code, notes, and snippets.

Jacqui jacquibo

View GitHub Profile
View ImportDistinctDataWithRelationships.adoc

Import Distinct Data With Relationships

Import Distinct Data from a CSV file, and create relationships

Here is an example of importing distinct data from a CSV file, and creating relationships using that data.

Graph Population

This method is more efficient than just using MERGE. It never tries to match any duplicates from the csv file as they are filtered out beforehand. It still uses MERGE to ensure that duplicate nodes are not created, but in this situation this would only be required if the csv file was loaded more than once.

View ImportDistinctData.adoc

Import Distinct Data

Import Distinct Data from a CSV file

Here are two methods for importing only distinct data from a CSV file, without having to pre-process the CSV for duplicates. Method 2 is more efficient than Method 1.

Graph Population Method 1

View ClearDb.cs
private void ClearDb(IGraphClient client)
{
client.Cypher
.Match("(n)")
.DetachDelete("n")
.ExecuteWithoutResults();
}
@jacquibo
jacquibo / DropColumnIfExists.sql
Created Apr 5, 2016
Drop a column, using SQL, if it exists
View DropColumnIfExists.sql
IF exists( select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='myTable' and COLUMN_NAME='columnToDrop')
BEGIN
ALTER TABLE myTable drop COLUMN columnToDrop
END
@jacquibo
jacquibo / existing.sql
Created Mar 24, 2016
Adding a relationship constraint to an existing or new column in MS SQL
View existing.sql
ALTER TABLE [dbo].[MyTable]
ADD CONSTRAINT FK_MyTable_OtherTable FOREIGN KEY (OType)
REFERENCES [dbo].[OtherTable] (Ident)
ON DELETE CASCADE
ON UPDATE CASCADE
View calendar.adoc

Calendar

Initial Data Setup

View Entity-Framework-Seed-Problem
// Seed code from Configuration.cs
protected override void Seed(DAL.Models.Context context)
{
// This method will be called after migrating to the latest version.
// Default Customers - create
var customers = new[]{
new Customer { Name = "cust_a" },
new Customer { Name = "cust_b" },
View BabyNames2.adoc

Baby Names Graph

Initial Data Setup

@jacquibo
jacquibo / BabyNames
Last active Aug 29, 2015
Baby Names Graph Gist
View BabyNames
== Baby Names Graph
:neo4j-version: neo4j-2.1
:author: Jacqui Read
:twitter: @tekiegirl
=== Initial Data Setup
//setup
//hide
@jacquibo
jacquibo / navigation.adoc
Last active Jun 3, 2019
A neo4j graph gist showing how satellite navigation mapping can be modelled in a graph.
View navigation.adoc

Roads, Nodes and Automobiles

or 'How a sat-nav could use a graph database'


You can’t perform that action at this time.