开发者

Is there a sample MongoDB Database along the lines of world for MySql? [closed]

开发者 https://www.devze.com 2023-02-27 08:38 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

Improve this question

As someone new to Mongo, I am looking for a sample MongoDB database that I can import and p开发者_运维问答lay with. Something along the lines of world for mysql or Northwind for MSSQL.

Is there one? (I couldn't find any reference to one at http://www.mongodb.org nor did my googling help)


I found this you can import the json data with:

mongoimport --db scratch --collection zips --file zips.json

I guess that you can import any json data that you find, it also supports csv and tsv. Hope this helps.


For *NIX/Mac OS this can be done in two simple steps

wget http://media.mongodb.org/zips.json
mongoimport -v --file=zips.json

For Windows users: Please follow the following steps to import from the json file if you are using windows 7:

  • Download the above mentioned JSON file and place it inside a folder (say d:\sample)
  • Open a command prompt, start the mongo server by going in to the bin directory and typing in mongoD
  • Now take another command prompt and go to the bin directory again and write the following command

    C:\mongodb\bin>mongoimport --db test --collection zips --file d:\sample\zips.json

  • The import should start working immediately and at the end it should show something like this : Thu Dec 19 17:11:22 imported 29470 objects

That's it!


This doesn't have everything, but it is a nice step towards getting Northwind on MongoDB:

https://github.com/tmcnab/northwind-mongo


Download the collection of Northwind csv files from https://github.com/tmcnab/northwind-mongo/archive/master.zip

Execute following command to import csv into mongodb

mongoimport -d Northwind -c categories --type csv --file categories.csv --headerline
mongoimport -d Northwind -c customers --type csv --file customers.csv --headerline
mongoimport -d Northwind -c employee-territories --type csv --file employee-territories.csv --headerline
mongoimport -d Northwind -c employees --type csv --file employees.csv --headerline
mongoimport -d Northwind -c northwind --type csv --file northwind.csv --headerline
mongoimport -d Northwind -c order-details --type csv --file order-details.csv --headerline
mongoimport -d Northwind -c orders --type csv --file orders.csv --headerline
mongoimport -d Northwind -c products --type csv --file products.csv --headerline
mongoimport -d Northwind -c regions --type csv --file regions.csv --headerline
mongoimport -d Northwind -c shippers --type csv --file shippers.csv --headerline
mongoimport -d Northwind -c suppliers --type csv --file suppliers.csv --headerline
mongoimport -d Northwind -c territories --type csv --file territories.csv --headerline

This can be used for both Windows and Liinux OS


After downloading Northwind data as per @tslater, I cleaned it up a bit..

Is there a sample MongoDB Database along the lines of world for MySql? [closed]

And ran the following PowerShell command to import into the mongo:

Get-ChildItem "C:\MongoDb\samples\northwind\csv" -Filter *.csv | `
Foreach-Object {
    C:\MongoDb\bin\mongoimport.exe -h localhost:55000 -d northwind -c $_.BaseName --type csv --file $_.FullName --headerline 
}


http://docs.mongodb.org/manual/tutorial/aggregation-zip-code-data-set/ provides a json file at the link : http://media.mongodb.org/zips.json which is zip code data.

This can be used for Map-Reduce, Aggregation and Grouping queries learning purposes and the above tutorial link at MongoDB also shows how.

For Windows: You can install a MongoVUE tool (from http://www.mongovue.com) , which is IDE for MongoDB shell operations and also provides Map-Reduce, Aggregation and Filtering support as well as data import from MySQL databases to MongoDB.

The JSON file at the link above has 3 duplicate _id entries which will hinder the import process a bit and you may have to do removeall for inserted documents. But in the end you should have 29,467 documents in your collection.

Is there a sample MongoDB Database along the lines of world for MySql? [closed]


You can create TPC-H benchmark data-sets and import them.

Example import for lineitem table:

./mongoimport -d test -c lineitem --type csv -f  l_orderkey,l_partkey,l_suppkey,l_linenumber,l_quantity,l_extendedprice,l_discount,l_tax,l_returnflag,l_linestatus,l_shipdate,l_commitdate,l_receiptdate,l_shipinstruct,l_shipmode,l_comment --file /home/metdos/mongo/tpc-h/tpch_2_13_0/lineitem.tbl


I am updating movies collection, whenever get free time. Personally it is very useful for me as it contains embedded object, array field, string field, date field. Click here to get JSON file of movie collection

Demo of one document

{
    "_id" : ObjectId("5692a15524de1e0ce2dfcfa3"),
    "title" : "Toy Story 4",
    "year" : 2011,
    "rated" : "G",
    "released" : ISODate("2010-06-18T04:00:00.000Z"),
    "runtime" : 206,
    "countries" : [ 
        "USA"
    ],
    "genres" : [ 
        "Animation", 
        "Adventure", 
        "Comedy"
    ],
    "director" : "Lee Unkrich",
    "writers" : [ 
        "John Lasseter", 
        "Andrew Stanton", 
        "Lee Unkrich", 
        "Michael Arndt"
    ],
    "actors" : [ 
        "Tom Hanks", 
        "Tim Allen", 
        "Joan Cusack", 
        "Ned Beatty"
    ],
    "plot" : "The toys are mistakenly delivered to a day-care center instead of the attic right before Andy leaves for college, and it's up to Woody to convince the other toys that they weren't abandoned and to return home.",
    "poster" : "http://ia.media-imdb.com/images/M/MV5BMTgxOTY4Mjc0MF5BMl5BanBnXkFtZTcwNTA4MDQyMw@@._V1_SX300.jpg",
    "imdb" : {
        "id" : "tt0435761",
        "rating" : 8.4,
        "votes" : 500084
    },
    "tomato" : {
        "meter" : 99,
        "image" : "certified",
        "rating" : 8.9,
        "reviews" : 287,
        "fresh" : 283,
        "consensus" : "Deftly blending comedy, adventure, and honest emotion, Toy Story 3 is a rare second sequel that really works.",
        "userMeter" : 89,
        "userRating" : 4.3,
        "userReviews" : 602138
    },
    "metacritic" : 92,
    "awards" : {
        "wins" : 56,
        "nominations" : 86,
        "text" : "Won 2 Oscars. Another 56 wins & 86 nominations."
    },
    "type" : "movie",
    "reviews" : [ 
        {
            "date" : ISODate("2017-02-13T04:00:00.000Z"),
            "name" : "parvesh",
            "rating" : 8.9,
            "comment" : "My first review for Toy Story 3, hoping it will execute while trying for the very first time."
        }, 
        {
            "date" : ISODate("2017-02-13T04:00:00.000Z"),
            "name" : "Prabhash",
            "rating" : 9.3,
            "comment" : "My second review for Toy Story 3, hoping it will execute while trying for the very first time."
        }, 
        {
            "date" : ISODate("2017-02-11T04:00:00.000Z"),
            "name" : "praveen",
            "rating" : 6.7,
            "comment" : "My third review for Toy Story 3, hoping it will execute while trying for the very first time."
        }
    ]
}
0

精彩评论

暂无评论...
验证码 换一张
取 消