<commit_before>{
 "metadata": {
  "name": "",
  "signature": "sha256:04d3c24e730143dad9aa1d3220693b5d307b4cef606dd301fcfebb9a1790d507"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Cassandra Data Modeling Refresher\n",
      "=================================\n",
      "\n",
      "By <NAME>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Overview\n",
      "==========\n",
      "This is a quick refresher into Cassandra data modeling.  We're going to go over keyspace and table creation first, then dig into how CQL translates to table layout.\n",
      "\n",
      "We're going to use the ipython-cql extension extension which lets us run CQL queries directly from IPython notebook.  It's available on pypi as `ipython-cql`."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%load_ext cql"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Keyspaces\n",
      "====================\n",
      "\n",
      "A keyspaces is a container for tables in Cassandra.  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%cql CREATE KEYSPACE IF NOT EXISTS tutorial WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%keyspace tutorial"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Tables\n",
      "==============\n",
      "\n",
      "Tables are where our data lives.  It is similar in concept to a table in a RDBMS, but behaves differently.  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%cql\n",
      "\n",
      "CREATE TABLE IF NOT EXISTS user (\n",
      "  user_id uuid,\n",
      "  name text,\n",
      "  PRIMARY KEY (user_id)\n",
      ")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Partitions\n",
      "============\n",
      "\n",
      "Within a table, data lives in a partition."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Rows\n",
      "=====\n",
      "\n",
      "Within a partition can exist many \n"
     ]
    }
   ],
   "metadata": {}<commit_msg>adding like<commit_after>{
 "metadata": {
  "name": "",
  "signature": "sha256:08136eebd6a3e40d356e2a9fad5f16ceb5deadbdcb6eba5e2e4a76e5de73fa05"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Cassandra Data Modeling Refresher\n",
      "=================================\n",
      "\n",
      "By <NAME>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Overview\n",
      "==========\n",
      "This is a quick refresher into Cassandra data modeling.  We're going to go over keyspace and table creation first, then dig into how CQL translates to table layout.\n",
      "\n",
      "We're going to use the ipython-cql extension extension which lets us run CQL queries directly from IPython notebook.  It's available on pypi as `ipython-cql`."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%load_ext cql"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Keyspaces\n",
      "====================\n",
      "\n",
      "A keyspaces is a container for tables in Cassandra.  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%cql CREATE KEYSPACE IF NOT EXISTS tutorial WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%keyspace tutorial"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Tables\n",
      "==============\n",
      "\n",
      "Tables are where our data lives.  It is similar in concept to a table in a RDBMS, but behaves differently.  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%cql\n",
      "\n",
      "CREATE TABLE IF NOT EXISTS user (\n",
      "  user_id uuid,\n",
      "  name text,\n",
      "  PRIMARY KEY (user_id)\n",
      ");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%cql\n",
      "CREATE TABLE IF NOT EXISTS like (\n",
      "  photo_id uuid,\n",
      "  user_id uuid,\n",
      "  primary key (photo_id, user_id)\n",
      ");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 13
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Partitions\n",
      "============\n",
      "\n",
      "Within a table, data lives in a partition."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Rows\n",
      "=====\n",
      "\n",
      "Within a partition can exist many \n"
     ]
    }
   ],
   "metadata": {}
{'fraction_non_alphanumeric': 0.20668589852367214, 'fraction_numerical': 0.014254199898184286, 'mean_word_length': 2.021014864172219, 'pattern_counts': {'":': 108, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2533955', 'n_tokens_mistral': 2076, 'n_tokens_neox': 1983, 'n_words': 479}