Presentation is loading. Please wait.

Presentation is loading. Please wait.

I have to Support What?!?!?! A Side by Side comparison of SQL Server, Oracle, and MongoDB.

Similar presentations


Presentation on theme: "I have to Support What?!?!?! A Side by Side comparison of SQL Server, Oracle, and MongoDB."— Presentation transcript:

1 I have to Support What?!?!?! A Side by Side comparison of SQL Server, Oracle, and MongoDB

2 About Paychex Paychex is a leading provider of integrated human capital management solutions for payroll, HR, retirement, and insurance services. Backed by 47 years of industry expertise, Paychex serves approximately 605,000 payroll client as of May 31, 2017, across more than 100 locations and pays one out of every 12 American private sector employees.

3 About the Speakers: Kim
DBA since 2009 Currently working at Paychex Have worked at Xerox, FujiFilm, and Wegmans Have administered SQL Server, Oracle, and Netezza Have also touched Informix, Postgres, and Mongo Graduated from RIT Married, 2 kids (both in college) Member of PASS PASS Summit Program Committee 2013,14,15, and 2016 Twitter: @kstjacques LinkedIn:

4 About the Speakers: Mike
DBA since 2010 Currently working at Paychex Have worked at Paetec, Windstream, Thomson Reuters previously Have administered Oracle, MySQL, MariaDB, Cassandra, DB2 Using MongoDB for 4 years MongoDB Master 2016-present Graduated from Drexel University in Philadelphia Married, 4 kids Twitter: @mikegray831 LinkedIn: Blog:

5 About the Audience: YOU!
SQL Server Professionals Oracle Professionals MongoDB Professionals None of the above Kim

6 Agenda Introduction to MongoDB When to use SQL Server/Oracle/MongoDB
Terminology Differences Differences between SQL Server and Oracle Let’s Compare them All! Summary Questions? Kim

7 What is MongoDB? NoSQL (not only SQL) database Document Store Database
Stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time High availability through built-in replication and failover Horizontal scalability through sharding Mike

8 Table vs. Document Mike

9 Guidelines on when to use
Relational Databases (SQL Server and Oracle) NoSQL Database (MongoDB) Complicated querying, database transactions, and routine analysis of data Storing serialized arrays in JSON objects Referential integrity. ACID required Storing records in the same collection that have different fields or attributes Just about anything that fits in a relational model. Constantly changing schema Semi-structured data Mike

10 (SQL Server and Oracle)
Terminology Relational Databases (SQL Server and Oracle) NoSQL Database (MongoDB) Table Collection Row Document Column Field Mike

11 SQL Server and Oracle Differences

12 SQL Server and Oracle are Different
T-SQL vs PL/SQL Instance/Database/Schema SQL - Instance - container for system objects and datafiles. SQL - Database - container for schemas and their associated objects. Oracle - Database - container for system information and schemas Oracle - Schema - container for datafiles and objects. Error Log vs Alert Log Active/Active DBOwner Transact SQL vs Procedural Language SQL TOP vs rownum in where clause / GO SQL - Instance - container for system objects and datafiles. SQL - Database - container for schemas and their associated objects. Oracle - Database - container for system information and schemas Oracle - Schema - container for datafiles and objects.

13 Database Creation Kim: Mike and I decided the office could really use a puppy dog. Picking the right dog is tough so we decided we needed a database to help aid us in the decision making process.

14 Create Database Oracle SQL Server MongoDB
Create database <dbname> <Parameters>…; EXAMPLE: CREATE DATABASE Dogs USER SYS IDENTIFIED BY password USER SYSTEM IDENTIFIED BY password LOGFILE GROUP 1 ('C:\oraclexe\app\oracle\oradata\Dogs\dogs_redo01.log') SIZE 100M, GROUP 2 ('C:\oraclexe\app\oracle\oradata\Dogs\dogs_redo02.log') SIZE 100M EXTENT MANAGEMENT LOCAL DATAFILE 'C:\oraclexe\app\oracle\oradata\Dogs\dogs_system01.dbf' SIZE 325M REUSE ... ---OR USE DBCA--- SQL Server MongoDB Create database <dbname> Example: CREATE DATABASE Dogs; use <database name> db.<collection name>.insert({field: value}) Example: use dogs db.breeds.insert({ “group” : “Hound”, type: “Basset”}) Kim Call out the difference with database and instances. Not Apples to apples DBCA - Database Configuration Assistant

15 Object Creation

16 Create a Table SQL Server Oracle MongoDB CREATE TABLE
[ database_name . [ schema_name ] . | schema_name . ] table_name ( { <column_definition> } [ ,...n ] ) [ ; ] Example: CREATE TABLE Dogs.dbo.Basset ( DogID int, Name varchar(30), EarLength int ); create table <table_name> (columns datatypes) tablespace tablespace_name; Example: CREATE TABLE Basset ( DogID number, Name varchar(30), EarLength number ); use <database_name> db.createCollection(name, options) Example: use dogs db.createCollection(basset) Mike - We decided a Basset Hound was a must! Comment int is available but not used Oracle converts to a number 38

17 Add a Column SQL Server Oracle MongoDB
alter table <table_name> add new_field new_field_datatype; Example: USE DOGS; ALTER TABLE Basset ADD weight int; alter table <table_name> add ( new_field new_field_datatype); Example: ALTER TABLE Basset ADD column weight (number(5)); use <database_name> db.collection.update({},{$set: “new_field” :1}, {upsert:false, multi:true}) Example: use dogs db.basset.update({},{$set: “weight”: 1}, {multi: true}) Kim - Want to see how fit our Basset is

18 Create an Index SQL Server Oracle MongoDB
CREATE INDEX i1 ON t1 (col1); Example: USE DOGS; CREATE INDEX IX_DogID ON Basset(DogID); Create index <index_name> on <table_name> <options>; Example: CREATE INDEX DogID_IDX ON Basset(DogID); use <database_name> db.collection.createIndex(keys, options) Example: use dogs db.basset.createIndex({DogID}) Mike

19 Remove a Column SQL Server Oracle MongoDB
alter table <table_name> drop column <column_name>; Example: ALTER TABLE Basset DROP COLUMN EarLength; use <database_name> db.collection.update({},{$unset: “new_field” :1}, {multi:true}) Example: use dogs db.basset.update({},{$unset : “EarLength” : 1}, {multi: true}) alter table <table_name> drop column <column_name>; Example: USE DOGS; ALTER TABLE Basset DROP COLUMN EarLength; Kim - Bassets are a bit self conscious about there ears… especially if they are often mistaken for a beagle.

20 Create a Role SQL Server Oracle MongoDB CREATE ROLE roleName GO
EXAMPLE: USE Dogs; CREATE ROLE DogOwner; GRANT SELECT, INSERT, UPDATE, DELETE on Basset to DogOwner; CREATE ROLE roleName; Example: CREATE ROLE DogOwner; GRANT CREATE SESSION to DogOwner; GRANT SELECT, INSERT, UPDATE, DELETE on Basset to DogOwner; use admin db.createRole({ role: “roleName”, privileges: [ { resource: { db: “appDB”, collection: “”}, actions: [ “find” ]}], roles: [ { role: “read”, db: “admin” }]) EXAMPLE: db.createRole({ role: “DogOwner”, privileges: [{ resource: { db: “dogs”, collection: “basset”}, actions: [ “find”,”insert”,”update”,”remove”]}]) Mike Mongo - Create local role?

21 Create a User SQL Server Oracle MongoDB
CREATE LOGIN [<domainName>\<login_name>] FROM WINDOWS; CREATE LOGIN <login_name> WITH PASSWORD = '<enterStrongPasswordHere>'; USE DBName CREATE USER <new user name> FOR LOGIN <login name>; EXAMPLE: USE master; CREATE LOGIN Owner1 WITH USE Dogs; Create USER Owner1 FOR LOGIN Owner1; create user <username> identified by <password>; EXAMPLE: create user owner1 identified by P#ssw0rd; use admin db.createUser({ username: “username”, pwd: “changeMe”, roles: [ { role: “role1”, db: “appDB”}, { role: “role2”, db: admin”}]) EXAMPLE: db.createUser({ username: “mongodb”, pwd: “mongodb”, roles: [{ role: “dogOwner”, db: “basset”}]) Kim SQL Server security is a 2 step process. First you need to add a login so a user can access the SQL Server INSTANCE. Then you need to create a database user and map the user to a login so the user can access the database once connected to the instance.

22 Assign a Role to a User SQL Server Oracle MongoDB ALTER ROLE role_name
{ ADD MEMBER database_principal | DROP MEMBER database_principal | WITH NAME = new_name } Example: USE Dogs; ALTER ROLE DogOwner ADD MEMBER Owner1; grant role_name to username; Example: GRANT DogOwner to Owner1; use admin db.grantRolesToUser( “Username”, [ roles]) Example: db.grantRolesToUser(“Owner1”, [roles: {role: “DogOwner”, db: “basset”}]) Mike

23 CRUD Operations

24 Insert a Row SQL Server Oracle MongoDB
insert into <tablename> (column1,column2, column3, etc.) VALUES (value1, value2,value3, etc.); Example: INSERT INTO Basset VALUES (1,'Princess Buttercup', '65'); insert into <tablename> (column1,column2, column3, etc.) VALUES (value1, value2,value3, etc.); Example: INSERT INTO Basset VALUES (1,'Princess Buttercup', '65'); use <database_name> db.collection.insert({field: value}) Example: use dogs db.basset.insert({ _id: 1, “name” : “Princess Buttercup”, “weight” : 65}) Kim - Princess Buttercup

25 Find a Record SQL Server Oracle MongoDB
select * from <table_name> where <query>; Example: USE Dogs; SELECT * FROM Basset WHERE Name=’Princess Buttercup’; select * from <table_name> where <query>; Example: SELECT * FROM Basset WHERE Name=’Princess Buttercup’; use <database_name> db.collection.find(query, projection) Example: use Dogs db.basset.find(“name” : “Princess Buttercup”}) Mike

26 Delete a Row SQL Server Oracle MongoDB
Delete from <tablename> where <query>; Example: Delete from Basset where Dogid = 1 and name = ‘Princess Buttercup’ and Weight = 65; Delete from <tablename> where <query>; Example: Delete from Basset where Dogid = 1 and name = “Princess Buttercup” and weight = 65; use <database_name> db.collection.delete({query},{multi: true/false}) Example: use dogs db.basset.delete({ _id: 1, “name” : “Princess Buttercup”, “weight” : 65},{multi: true}) Kim - Princess Buttercup ate someone’s lunch off their desk so poor Princess Buttercup had to go.

27 Backup and Restores

28 Backup a Database SQL Server Oracle MongoDB Native SQL Server Backup
BACKUP DATABASE { database_name } TO <backup_device> [ ,...n ] [ <MIRROR TO clause> ] [ next-mirror-to ] [ WITH { DIFFERENTIAL | <general_WITH_options> [ ,...n ] } ] [;] Example: BACKUP DATABASE [Dogs] TO DISK = N'C:\Backups\Full_Dogs.bak' RMAN BACKUP INCREMENTAL LEVEL 0 DATABASE; Ops Manager Backup Cloud Manager Backup Mike Note that Mongo backups are GUI driven

29 Restore Database SQL Server Oracle MongoDB
RESTORE DATABASE { database_name } [ FROM <backup_device> [ ,...n ] ] [;] Example: RESTORE DATABASE [Dogs] FROM DISK = N'C:\Backups\Full_Dogs.bak' RMAN> STARTUP NOMOUNT; RMAN> RESTORE CONTROLFILE; RMAN> RESTORE DATABASE; RMAN> RECOVER DATABASE; RMAN> ALTER DATABASE OPEN RESETLOGS; Full -> Incremental -> OpLog *need each incremental taken between the time of the full and the PIT of restore. Then logs are applied. Kim cumulative incrementals Provide restore examples N’ denotes subsequent string is unicode

30 Cleanup

31 Drop a Table SQL Server Oracle MongoDB
drop table <table_name> <options>; Example: USE Dogs; DROP TABLE Basset; drop table <table_name> <options>; Example: DROP TABLE Basset; use <database_name> db.collection.drop() Example: use dogs db.basset.drop() Mike

32 Drop a Database SQL Server Oracle MongoDB
drop database <DBname> <options>; Example: USE Master; DROP DATABASE Dogs; drop database <DBname> <options>; Example: Drop database Dogs; db.<DB Name>.drop() Example: use admin db.dogs.drop() Kim - our adventures in dog ownership have come to an end and so we no longer need a database.

33 High Availability / Disaster Recovery

34 Common HA/DR Options SQL Server Oracle MongoDB Cluster:
SQL Server Failover Clustering DR/Replication: Always on SQL Replication Transactional Merge Snapshot Log Shipping Cluster: RAC DR/Replication: Dataguard Golden Gate Cluster: Sharding DR: Replica Sets Mike SQL Server Failover Clustering Installed on

35 Sql Server Availability Group
Kim Windows Server Failover Cluster

36 Oracle Data Guard Kim

37 MongoDB Replica Set Mike

38 MongoDB Sharding Mike

39 Storage Management Kim

40 How does each Database handle storage
SQL Server Oracle MongoDB Datafiles Example: USE [master]; ALTER DATABASE [Dogs] ADD FILE ( NAME = N'Dogs', FILENAME = N'C:\DATA\Dogs_02.ndf' , SIZE = 8192KB , FILEGROWTH = 65536KB ) TO FILEGROUP [PRIMARY]; ASM Datafiles alter tablespace basset add datafile ‘+ASM/dogs/datafiles/basset_data_02.dbf’ SIZE 1G autoextend until 32G; Storage Engines MMAPV1 (Memory Mapped Files, 32 MB, 64MB, 128MB….up to 2 GB) Wired Tiger - each collection has its own data files, as does each index. Data can grow up to the max size of the file system. Kim - SQL Mike Oracle and Mongo

41 Increasing Existing Datafile Size
SQL Server Oracle MongoDB Datafiles Example: USE master; ALTER DATABASE Dogs MODIFY FILE ( NAME = N'Dogs', SIZE = KB ); Datafiles Example: ALTER DATABASE datafile ‘+ASM/dogs/datafiles/basset_data_02.dbf’ RESIZE 100M; N/A Mike

42 Troubleshooting SQL Server Oracle MongoDB Error Log SQL Agent Log
Dynamic Management Views Performance Dashboard SP_WHO2 Activity Monitor Extended Events Profiler Perfmon Alert Log Listener Log Oracle Enterprise Manager Automatic Database Diagnostic Monitor (ADDM) Automated Workload Repository(AWR) Active Session History (ASH) Error Log/Profiler Ops Manager/Cloud Manager MongoDB Compass mtools mongostat mongotop Kim DMVs return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance Add ASH for Oracle ORACHK Spell out the Acronyms Add perfmon

43 Ways to connect with the User Community
SQL Server Oracle MongoDB PASS SQL Saturday PASS Summit Microsoft Ignite SQLIntersection GroupBy Local Group: PASS Pittsburgh Chapter IOUG Collaborate Oracle Open World Local Group: PittOUG MongoDB Sponsored Groups: MongoDB World Percona Database Conference Local Group: Pittsburgh MUG Kim

44 Summary Today we showed the similarities and differences of several operations within SQL Server, Oracle, and Mongo. The syntax may sometimes be different, however, the database concepts tend to remain the same. We hope this helps DBA’s who need to support multiple database platforms start to get a handle on the differences and similarities between SQL Server, Oracle, and MongoDB. Mike

45 Questions?

46 Thank You!


Download ppt "I have to Support What?!?!?! A Side by Side comparison of SQL Server, Oracle, and MongoDB."

Similar presentations


Ads by Google