Rajat Hubli wrote:
> Hello Everyone,
>
> Finally after some hours of discussion on the schema and getting it
> right now i finally want to move my data from Oracle to Mongo. So i
> would like to know whats the procedure and the tool to do the same?
> I was looking at Toad for cloud database as a tool for the same but
> it seems a little complicated (may be to me as i am using it for the
> first time). So according to me these would be the steps as follows
> to move the data: 1] Defining the mongo schema on paper.
MongoDB is +schemaless+
> 2] How to create this schema in Mongo?
MongoDB is +schemaless+
> Do i have to enter some dummy values and create the schema or
> actually take on of my rows from the Oracle table and enter it
> manually in Mongo and then later export data from Oracle?
You export your data somehow from Oracle and turn it into JSON with
a structure according to your needs and then save the data into MongoDB.
Once again: MongoDB is +schemaless+ - every document can have its *own*
schema.
What is the real question?
- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGTBAEBAgAGBQJOQUi2AAoJEADcfz7u4AZjcpQLtA1aWh3D0pCHL9WnYcqqGeEr
yq0wU7dvoFI2jPIVQfsiIiLy28BxJdrNjR4eCAIcsxZL/zooeR/4uH0MaEuF9u4Z
+eAwY8dIFGTu8WlTRkszk3OOR1iAAi+CQKYuyCWIJX0sRlr7cOtykvBKgdex+12g
F4D30Ij+I1V51Y9gGMdRHrLRvaVHwrzTbWm5jHXpJTMvPi79GuNI9ATLLXFqlyrA
rD+94ygX0R3izXZc9RugeMZVH/rYGMHgOsufhktRUUTpmCa5QP0NVuBQqeEcWCa+
C6syFjAWqk9UQXKaj11dkGB95kgLDcmGHFEpncPUhOwLFUCxCV1R7n9dgBVQVyXi
8Z+OTm8+cksNvyBEhM2mYcGnQwzAWuke0+l+3NIeleRJRJOz717kbbYzed3IoORE
s0YxHv0jtB99/PfYZbfC1CS9fgnO7gIVh6X0ac9xX5u7caFCgKcF1GOAagdYmhMp
QMG112Kib0SFoTu84qPlZgzAVDllBw==
=qhYi
-----END PGP SIGNATURE-----
set Ruby-OCI prefetch to a few thousand rows at a time
select out of Oracle
for each record retrieved
populate a Ruby hash as desired for your Mongo schema
use YAJL to convert to JSON
insert into Mongo
Sometimes we'll break it up into several smaller Ruby applications. For example,
today I'm in the middle of exporting a few billion records and have one Ruby app that
extracts from Oracle and writes to gzipped files that are rotated every 4-5 million
records. Then there is a second app that we run that reads from gzipped file and
inserts into Mongo.
Total is about 400 lines of Ruby code.
Nathan Ehresman
Rajat Hubli wrote:
> Thanks Nathan for your inputs. I would like to know if its necessary
> to convert to .json. Mongo says it also accepts .csv files. And i
> have been hearing that its easier to export oracle data into .csv
> files. I know nothing about RUBY and thats bothering me a bit.
> However i would like to learn it for sure if i really need it. Could
> you help me out with some sample code which atleast explains me the
> algorithm of what i am exactly supposed to do and then i could write
> my own program.
If you are developer and familar with Oracle then you should be able
to write some script or program in your favorite language fetching the
related rows/data from Oracle and converting it into either JSON
or CSV. No idea how one would imported "embedded" documents through
CSV...so JSON is the favorite destination format to be used
through mongoimport. Where is your particular problem? It should obvious
that such a migration is specific to your own needs and requirements. So
what exactly do you need?
- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJOQjerAAoJEADcfz7u4AZjnS0Lv0XaptC+j5RHVFtfZiED0yau
nHWy4g+eabk5+Xrak2HyplCzGIdYSaronDFWrugmANlOLb7WrNm6v/dIX5xh79eO
atsjN0QLPHX8Jdrk+UPxxXJ8ioWlWl2MUMkkzCoqk8ehI1f0QwXH6CQAzPg4j2tp
0NZFZRFiDGpbyjarFBQkZdSAcyoy/2VWYVNOoZImLpcKQdTW3hqVMKc7CO65YHv5
Pkwd8QYqnO76rpcp7kYWTC8i9WtyglSP5C/ZdFeJLGdVaRJYeh6h5F3mjhNvrDvi
+C+enet5s+wESa6hBNYRLcwSWA3SFQlVY/b2eVOVCBTgq1luU4dqBzXJjJFGbilu
UTUWjWWYEN3RPc+VxnXPFZPVM3OZuo7Q9EIOUQvtViGR5fYOrucIAYwM0nkM+GWD
TeEGVKPuPkzXW0tHW5qYz42w0yOgbAx+gLKgxpiNh8DtORPC+hUfV9Z6tJzbPo86
vmh0R5Kt1mmki5dHLkuI4Q8DdsQ+WTs=
=JzDF
-----END PGP SIGNATURE-----
Rajat Hubli wrote:
> Hi, I have designed a schema in Mongo which looks like this. Payment=
> { payment_id: name: creditcard_details: { last_digit: vendor: }
> banktransfer_details: { transfercode: bankname: }cashpayment_details:
> { agentname: cashcode: } } So basically it looks like three documents
> namely creditcard, banktransfer and cashpayment embeded inside a
> single document named payment.
As said: I don#t know how to manage embedded documents on the import
side through CSV - trivial with JSON. But anyway...you know your options.
- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJOQkbwAAoJEADcfz7u4AZjZQYLwNgFs0myKX6CxEexNT8IYzcO
7+lCpM79ycIDJEERBMbtrqKc/PkA9qcjqkOdRGkohNWUEEK7KwyMNMbYAFwwF8Eb
MjsD2G4ogBNHbYHzUKtR+2i3tzHDjq2Roa0CzRXMTrTU7L7wdUpDuQ9GjNGQQnWC
2krbZiT2JqxsOB8NgqVRThdfCHHt85ErIr6C99ZxUvc/v6QoC14zGMzVBATu6aG8
mpDkwtfCXRromt0GrG57d239JIGyY51cwjdtm+dFpOI5FTbhzz1aiLvavYicOhsq
vZvXsrTkxjddLrou+JO0KlpY4N4Xx/uI4qjWvwbUx94hkPfK6qbmf3Tj0B7BeI3J
+n0i6RW5TAhy5HThdKKXuHdX+/S01ckr+ZvKhf0CHhe6feY7zwMaJx+ODcK16jtY
XgzfOmHqUNwgK5OrW43pugoHtw3PBv6v1RXxu9gJXfq9hZJS+TnZ/LHw5MqW3xX8
zSimOrOSRycQtWwsqOwZ+ODKvpIS4II=
=zQpx
-----END PGP SIGNATURE-----
http://tebros.com/2011/07/using-mongodb-mapreduce-to-join-2-collections/
Alternately do the join in Oracle and as Andreas has said, just write a small app in
your language of choice and after selecting your data out of Oracle, dump JSON out.
There are good JSON libraries in just about every language I can think of.
Nathan Ehresman
Rajat Hubli <hublirajat@...> writes:
>
> Thats perfect. I would work on that now..Thanks a lot
>
> On Aug 10, 5:55 pm, Steve Francia <st...@...> wrote:
> > the script will directly be querying your oracle database and inserting it
> > directly into mongo. No exporting or files at all.
>
Nathan, Rajat and all,
Why are you moving from Oracle to MongoDB?
Is it for a new application that needs some function that Oracle cannot provide?
If so, what function? or is it primarily to save cost?
Rajat, sounds like you are trying to take an existing application and
rewrite it so that you could use MongoDB, and I am curious what is driving that?
I have not seen many existing apps being rewritten from using a commercial RDBMS
to NoSQL, hence my question.
Thanks!