All Projects → ignoreintuition → Jschema

ignoreintuition / Jschema

Licence: mit
A simple, easy to use data modeling framework for JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jschema

Data Science Hacks
Data Science Hacks consists of tips, tricks to help you become a better data scientist. Data science hacks are for all - beginner to advanced. Data science hacks consist of python, jupyter notebook, pandas hacks and so on.
Stars: ✭ 273 (+4.6%)
Mutual labels:  dataset, data, data-visualization
Filterizr
✨ Filterizr is a JavaScript library that sorts, shuffles and filters responsive galleries using CSS3 transitions ✨
Stars: ✭ 546 (+109.2%)
Mutual labels:  sort, filter, javascript-library
Datagear
数据可视化分析平台,使用Java语言开发,采用浏览器/服务器架构,支持SQL、CSV、Excel、HTTP接口、JSON等多种数据源
Stars: ✭ 266 (+1.92%)
Mutual labels:  dataset, data, data-visualization
Ac D3
Javascript Library for building Audiovisual Charts in D3
Stars: ✭ 76 (-70.88%)
Mutual labels:  data, data-visualization, javascript-library
Javascript
A repository for All algorithms implemented in Javascript (for educational purposes only)
Stars: ✭ 16,117 (+6075.1%)
Mutual labels:  hacktoberfest, data-structures, sort
Openrefine
OpenRefine is a free, open source power tool for working with messy data and improving it
Stars: ✭ 8,531 (+3168.58%)
Mutual labels:  data-structures, data, data-visualization
Data Science Resources
👨🏽‍🏫You can learn about what data science is and why it's important in today's modern world. Are you interested in data science?🔋
Stars: ✭ 171 (-34.48%)
Mutual labels:  dataset, data, data-visualization
Java
All Algorithms implemented in Java
Stars: ✭ 42,893 (+16334.1%)
Mutual labels:  hacktoberfest, sort, data-structures
C
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
Stars: ✭ 11,897 (+4458.24%)
Mutual labels:  hacktoberfest, data-structures, sort
Geeksforgeeks Dsa 2
This repository contains all the assignments and practice questions solved during the Data Structures and Algorithms course in C++ taught by the Geeks For Geeks team.
Stars: ✭ 53 (-79.69%)
Mutual labels:  hacktoberfest, data-structures, data
Go Algorithms
Algorithms and data structures for golang
Stars: ✭ 1,529 (+485.82%)
Mutual labels:  hacktoberfest, data-structures, sort
C Plus Plus
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Stars: ✭ 17,151 (+6471.26%)
Mutual labels:  hacktoberfest, data-structures, sort
Dailycodebase
2 month data structures and algorithmic scripting challenge starting from 20th December 2018 - Coding is Fun! 💯💯 Do it everyday!! Also, Do give us a ⭐ if you liked the repository
Stars: ✭ 186 (-28.74%)
Mutual labels:  hacktoberfest, data-structures
Data Structures And Algorithms Hacktoberfest18
List of data structures and algorithms. Feel free to contribute under Hacktoberfest '18!
Stars: ✭ 187 (-28.35%)
Mutual labels:  hacktoberfest, data-structures
Programmers Community
This repository contains various solution of a problem in Ruby, C, C++, Python and Java.
Stars: ✭ 189 (-27.59%)
Mutual labels:  hacktoberfest, data-structures
Climate Change Data
🌍 A curated list of APIs, open data and ML/AI projects on climate change
Stars: ✭ 195 (-25.29%)
Mutual labels:  hacktoberfest, data
Plotly.js
Open-source JavaScript charting library behind Plotly and Dash
Stars: ✭ 14,268 (+5366.67%)
Mutual labels:  hacktoberfest, data-visualization
Free Ai Resources
🚀 FREE AI Resources - 🎓 Courses, 👷 Jobs, 📝 Blogs, 🔬 AI Research, and many more - for everyone!
Stars: ✭ 192 (-26.44%)
Mutual labels:  hacktoberfest, data
Rust
All Algorithms implemented in Rust
Stars: ✭ 4,562 (+1647.89%)
Mutual labels:  hacktoberfest, data-structures
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (-23.75%)
Mutual labels:  hacktoberfest, data-visualization

jSchema

logo

Data Modeling in JavaScript

jSchema is a framework for modeling data in JavaScript. By using fundamental data modeling principles you are able to pull multiple datasets into a common schema, define relationships, aggregate, join, and subset datasets to make data easier to work with in the browser.

entity relationship diagram - new page 1

jSchema is going to create an object called jSchema. This object is a metadata representation of all your datasets containing the table names, column names, and keys that define sets. The data itself is stored in a closure within the object and is retrieved via a getter function. Joining data, aggregating data, and filtering data will create a new dataset in your WORK namespace that will persist on the page until either you delete the table or you run a cleanUp method. By default jSchema will be case sensitive. This can be overwritten with:

var s = new jSchema({
  "caseSensitive": false
});

Demo

A complete working demo of how to load tables, join tables, and aggregate tables can be found in the repository in the demo folder. A live demo can be found on the libraries homepage: live demo

How to Use

NPM

If you use npm, npm install jschema.

requirejs

jschema.js uses requirejs to modularly load the library and is included in the package.json. requirejs can be moved to the lib directory of your project and included as:

<script data-main="main" src="lib/require.js"></script></body>

where main is main.js. You can then add jSchema to your application as such (in this case main.js):

requirejs(['lib/jschema'], function(jSchema){
  var s = new jSchema;

  s.add([{a:1, b:2}])
  s.add([{b:2, c:3}], {name:"named_table", primaryKey:"b"})
});

Or load data from external sources:

fetch("education.json")
  .then(response => response.json())
  .then(json => s.add(json, {name:"education", primaryKey:"Age_Group"}))
  .then(fetch("gender.json")
    .then(response => response.json())
    .then(json => s.add(json, {name:"gender", primaryKey:"Age_Group"}))
);

JOIN

Multiple datasets that have primary / foreign key relationships can be joined as such:

s.join("EDUCATION", "GENDER", {name: "joinTable"})

DROP

You can drop tables that are no longer needed in the schema with the drop method:

s.drop("GENDER")

SORT

If you want to sort a dataset by an attribute use the orderBy method:

s.orderBy("GENDER", {
  clause: "Count",
  order: "asc",
  name: "sortBy"
})

GROUP BY

To Group by you need to provide the dataset name, the name of the dimension to group by, and the metrics you wish to aggregate:

s.groupBy("GENDER", {
  dim: "Gender",
  metric: "Count",
  name: "groupBy",
  method: "sum", // supported methods are sum, count, average, min, max
  percision: 2, // default is 2
  dimName: "GenderPK" // use if you need to rename the dimension
})

Output:

  {
    "dim": "Male",
    "val": 37575
  },
  {
    "dim": "Female",
    "val": 44074
  }
]

FILTER

To filter a dataset you can call the filter method and pass three or more arguments. First argument is always the table name. The second and third are the field to filter by, and the value to filter it on. Additional pairs can be included as fourth, fifth parameters and so on. A filtered dataset will be created in the WORK namespace.

s.filter('GENDER', 'Gender', 'Female')

UPDATE

If a new version of the dataset is made available you can update the existing table in the schema by running the update method:

s.update("GENDER", data);

INSERT

Inserting data into a table will add additional rows to your table. This will not affect any of the existing data in the table. A single row can be passed as an object or an array of objects can be passed. Column names need to match in order for the new data to appear when retrieved.

s.insert("TABLE0", {
  "gender": "Female",
  "age_group": "16-24",
  "count": 10
});

REMOVE COLUMNS

If you want to completely remove a column use removeCol to create a clone of the table with the column removed. Pass the dataset as the first argument and the attributes as the second argument. Attributes are col for the column to be removed, and name for the name of the table to clone the table to. Name is optional and if it is not used it will copy the data to the WORK namespace.

s.removeCol("COMPLETE", {
  "col": "REFUGEES_BY_DEST.STATE",
  "name": "REFUGEES_CLEAN"
});

ADD COLUMNS

In order to add a new column to a dataset you need to call the addCol method. This will take an expression (two columns and an arithmetic operator) and combine them into a new field. The function will create a new dataset with the name passed in the attribute name , and will return the schema object. If name is not provided it will create a dataset in the WORK namespace.

s.addCol("REFUGEES_CLEAN", {
  "name": "REFUGEES_ARITHMETIC",
  "expression": "REFUGEES_BY_DEST.VAL / POPULATION.POP_EST_2014",
  "colName": "AVG_POP_DEST"
})

By default all temporary datasets (joins, group by, order by) added to the schema will be prefixed with the namespace WORK. (e.g. joining two tables NAMES and LOCATIONS will result in a table added to the schema called WORK.NAMES_LOCATIONS). Calling the cleanUp method will remove all datasets added to the WORK namespace

s.cleanUp();

Testing

To run mocha test scripts from the terminal type:

npm install
npm run test

Contact

Questions, comments, feature requests, etc are always welcome. I am @ignoreintuition on Twitter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].