So sánh mongodb và mysql khi phỏng vấn

MySQL is a relational database management system, while MongoDB is a NoSQL database system. You can read more about these at the What is a Relational Database? and What is NoSQL? pages.

MySQL uses SQL, which most developers have experience with. Conversely, MongoDB uses MongoDB Query Language (MQL). While there are similarities between MQL and SQL, MQL typically requires a bit of extra work to learn.

Next, we cover some other key differences.

Data model

MySQL is a relational database system that stores data in columns, rows, and tables. You store data in rows, with each column representing a different type of data. You then define relationships between data by using foreign keys and primary keys. Each table has a primary key that you use to identify it, with the foreign key creating a relationship.

MongoDB is a document-oriented database that stores all of its data as Binary JSON (BSON) documents. BSON allows you to serialize many forms of data. Using BSON documents allows you to store unstructured, semi-structured, and structured data. Instead of a database schema, MongoDB uses a flexible approach, storing documents in collections.

Scalability

In a MySQL database system, the available options for scaling are limited. You can choose from these options:

  • Vertical scalability by adding more resources to the current database server
  • Read replication by creating read-only copies of the database on other servers

Read replication is restricted to a maximum of five copies. Replicas may also lag behind the main copy, which creates performance issues at scale. Vertical scalability is also limited to the infrastructure you use.

In contrast, MongoDB design offers a significant advantage in terms of scalability. It has two key features for scaling:

  • Replica sets—groups of MongoDB servers that hold identical data
  • Sharding—different parts of your data distributed across different servers

MongoDB allows you to create sharded clusters, so portions of your data are replicated across multiple servers. For example, if you have a large number of customer records, you can distribute them so that names from A-J and names from K-Z are in their own replica set. MongoDB can thus scale horizontally to optimize both read and write performance at scale.

Performance

MySQL is designed to enact high-performance joins across multiple tables that are appropriately indexed. However, it requires data to be inserted row by row, so write performance is slower.

MongoDB documents follow a hierarchical data model and keep most of the data in a single document, reducing the need for joins across multiple documents. Joins are supported via the $lookup operation, but they are not optimized for performance. However, MongoDB offers an insertMany() API for rapidly inserting data, prioritizing write performance.

Flexibility

As a relational database management system, MySQL has a more rigid structure than MongoDB. MySQL uses a fixed schema and organizes data into a row and table. You have to structure data and fit it into a tabular system to use MySQL.

By storing data as JSON documents, MongoDB lets you build complicated applications with many distinct data types. For instance, you can create new fields by updating nested array fields. You can also use an aggregation pipeline—a MongoDB feature that lets you transform data by combining multiple operations into a single workflow.

Access control

Within MongoDB, you can control access on an operation, collection, or database level. It uses Kerberos, X.509, and LDAP certificates to authenticate users. In contrast, MySQL allows you to restrict user access on a user, database, and table level. MySQL uses its own authentication system. It presents an additional security vulnerability in SQL injection attacks, which MongoDB’s schema-free approach avoids.

Data Engineering là một trong những công việc hấp dẫn nhất thế kỷ 21 bởi mức lương tốt và cơ hội việc làm rộng mở. Trong doanh nghiệp, Data Engineer chịu trách nhiệm thiết kế, xây dựng và bảo trì các luồng dữ liệu.

Vậy bạn cần học sử dụng những công cụ gì để trở thành một Data Engineer? Các kỹ năng cần thiết của một Data Engineer là gì? Hãy cùng Mellori tìm hiểu nhé!

1. Database tools

Lưu trữ, sắp xếp và quản lý khối lượng dữ liệu khổng lồ là rất quan trọng đối với vị trí Data Engineering. Do đó bạn cần có sự hiểu biết sâu sắc về thiết kế và kiến trúc cơ sở dữ liệu là rất quan trọng. Hai cơ sở dữ liệu thường được sử dụng là structured query language (SQL) và NoSQL-based. Trong khi các cơ sở dữ liệu dựa trên SQL như MySQL và PL/SQL được sử dụng để lưu trữ dữ liệu có cấu trúc được sử dụng các công nghệ như Cassandra, MongoDB và các công nghệ khác có thể lưu trữ khối lượng lớn dữ liệu theo yêu cầu của ứng dụng.

2. Data transformation tools - Công cụ chuyển đổi dữ liệu

Big data có mặt ở định dạng thô và không thể được sử dụng trực tiếp. Big data cần được chuyển đổi thành định dạng tiêu thụ dựa trên trường hợp sử dụng để xử lý nó. Chuyển đổi dữ liệu có thể đơn giản hoặc phức tạp tùy thuộc vào các nguồn dữ liệu, định dạng. Chính vì vậy mà bạn cần biết và sử dụng thành thạo một số công cụ chuyển đổi dữ liệu. Một số công cụ chuyển đổi dữ liệu phổ biến như HEVO, Matillion, Talend, Pentaho Data Integration, InfoSphere DataStage v.v.

3. Data ingestion tools - Công cụ nhập dữ liệu

Nhập dữ liệu là một trong những phần thiết yếu của các kỹ năng dữ liệu lớn và là quá trình di chuyển dữ liệu từ một hoặc nhiều nguồn đến nơi nó có thể được phân tích. Khi số lượng của dữ liệu tăng lên, việc nhập dữ liệu trở nên phức tạp hơn, yêu cầu các Data Engineer phải biết các công cụ nhập dữ liệu và API để ưu tiên các nguồn dữ liệu, xác minh chúng và gửi dữ liệu để đảm bảo quy trình nhập hiệu quả. Một số công cụ nhập dữ liệu cần biết là Apache Kafka, Apache Storm, Apache Flume, Apache Sqoop, Wavefront, v.v.

4. Data mining tools - Công cụ khai thác dữ liệu

Một kỹ năng quan trọng khác để xử lý Big Data là khai thác dữ liệu liên quan đến việc trích xuất thông tin quan trọng để tìm các mẫu trong các bộ dữ liệu lớn và chuẩn bị chúng để phân tích. Khai thác dữ liệu giúp thực hiện phân loại dữ liệu và dự đoán. Một số công cụ khai thác dữ liệu mà các chuyên gia dữ liệu lớn phải thực hành là Apache Mahout, Knime, Rapid Miner, Weka, v.v.

5. Data warehousing and ETL tools - Kho dữ liệu và các công cụ ETL

Data Warehouse và ETL giúp các công ty tận dụng Big Data một cách có ý nghĩa. Nó hợp lý hóa dữ liệu đến từ các nguồn không đồng nhất. ETL hoặc Extract Transform Load lấy dữ liệu từ nhiều nguồn, chuyển đổi nó để phân tích và tải dữ liệu đó vào warehouse. Một số công cụ ETL phổ biến bạn cần biết sử dụng là Talend, Informatica PowerCenter, AWS Glue, Stitch, v.v.