Difference between Oracle's table and Mongo's collection
Roughly speaking, the notion of 'Tables' in Oracle is similar to MongoDB's 'Collections'. They are NOT identical though. Before we examine the differences between Oracle's Table and MongoDB's Collection, let's see what Table in Oracle and Collection in MongoDB are. Table in Oracle: A table in Oracle is made up of a fixed number of columns for any number of rows. Every row in a table has the same columns. Collection in MongoDB: A collection in MongoDB is made up of documents. The concept of Documents is similar to rows in a table, but it's not identical. A document can have its own unique set of columns. In MongoDB, columns are called fields. So in MongoDB, fields are defined at the document level (or we can say in Oracle lingo that columns are defined at the row level), whereas in Oracle the columns are defined at the table level. That is actually the main difference between Oracle's Table and Mongo's collection among other subtle differences such as collections are schema-less, whereas Table in Oracle has to be in some schema. Example of an Oracle table: EMP EMPID NAME CITY 1 Smith Karachi 2 Adam Lahore 3 Jim Wah Cantt 4 Ken Quetta CREATE TABLE EMP (EMPID NUMBER(5),NAME VARCHAR2(20),CITY VARCHAR2(25)); INSERT INTO EMP VALUES (1,'SMITH','KARACHI'); INSERT INTO EMP VALUES (2,'ADAM','LAHORE'); INSERT INTO EMP VALUES (3,'JIM','WAH CANTT'); INSERT INTO EMP VALUES (4,'KEN','KARACHI'); Select * from EMP; In the above example, the table is 'EMP', with 4 rows. All 4 rows have a fixed number of columns EMPID, NAME, and CITY. Example of a MongoDB Collection: db.EMP.insert({EMPID: '1',NAME: 'Smith', CITY: 'Karachi'}) db.EMP.insert({EMPID: '2',NAME: 'Adam', CITY: 'Wah Cantt', Designation: 'CTO'}) db.EMP.insert({EMPID: '3,NAME: 'Jim', Designation: 'Technician'}) db.EMP.insert({EMPID: '4',NAME: 'Ken'}) > db.EMP.find() { "_id" : ObjectId("55d44757283d7d463aec4cc1"), "EMPID" : "1", "NAME" : "Smith", "CITY" : "Karachi" } { "_id" : ObjectId("55d44757283d7d463aec4cc2"), "EMPID" : "2", "NAME" : "Adam", "CITY" : "Wah Cantt", "Designation" : "CTO" } { "_id" : ObjectId("55d44757283d7d463aec4cc3"), "EMPID" : "3", "NAME" : "Jim", "Designation" : "Technician" } { "_id" : ObjectId("55d44757283d7d463aec4cc4"), "EMPID" : "4", "NAME" : "Ken" } In the above example, first we inserted 4 documents into collection 'EMP'. Notice that all 4 documents have different number of columns. db.EMP.find() command is to display these documents. Hope that helps......
Share this
You May Also Like
These Related Stories
oracle.com Account Locked - How to Access My Oracle Support?
oracle.com Account Locked - How to Access My Oracle Support?
Jun 22, 2010
1
min read
Migrating Oracle Workloads to Google Cloud - Cloud Spanner
Migrating Oracle Workloads to Google Cloud - Cloud Spanner
Dec 21, 2020
2
min read
getMOSPatch.sh - Downloading Patches From My Oracle Support
getMOSPatch.sh - Downloading Patches From My Oracle Support
Nov 11, 2013
4
min read
No Comments Yet
Let us know what you think