📖 Scenario: You are working as a junior data assistant in a company that uses different types of databases. Your manager wants you to create simple examples of three common types of databases: relational, NoSQL, and object-oriented. This will help the team understand how data is stored differently in each type.
🎯 Goal: Create three small database examples: one relational database table, one NoSQL document collection, and one object-oriented database class with objects. This will show how data is organized in each type.
📋 What You'll Learn
Create a relational database table named Employees with columns EmployeeID, Name, and Department.
Create a NoSQL collection named Products with at least two documents containing ProductID, Name, and Price.
Create an object-oriented database example with a class named Car having attributes make, model, and year, and create two objects.
💡 Why This Matters
🌍 Real World
Companies use different types of databases depending on their data needs. Understanding these types helps in choosing the right database for a project.
💼 Career
Database administrators and developers must know how to work with relational, NoSQL, and object-oriented databases to manage and organize data effectively.
Progress0 / 4 steps
1
Create a relational database table
Write SQL code to create a table called Employees with columns EmployeeID (integer), Name (text), and Department (text).
DBMS Theory
Hint
Use CREATE TABLE followed by the table name and define each column with its data type inside parentheses.
2
Create a NoSQL collection with documents
Write code to create a NoSQL collection named Products with two documents. Each document should have ProductID, Name, and Price fields. Use JSON format.
DBMS Theory
Hint
Use an array of JSON objects to represent the collection and documents.
3
Create an object-oriented database example
Write code to define a class named Car with attributes make, model, and year. Then create two objects of this class with example values.
DBMS Theory
Hint
Use a class with a constructor to define attributes, then create objects using new.
4
Complete the database examples
Add a comment at the end of the code summarizing the three types of databases: relational, NoSQL, and object-oriented.
DBMS Theory
Hint
Add a comment starting with // that briefly explains each database type.
Practice
(1/5)
1. Which type of database stores data in tables and uses SQL for queries?
easy
A. Object-oriented database
B. NoSQL database
C. Graph database
D. Relational database
Solution
Step 1: Understand database types
Relational databases organize data in tables with rows and columns.
Step 2: Identify query language
They use SQL (Structured Query Language) to manage and query data.
Final Answer:
Relational database -> Option D
Quick Check:
Tables + SQL = Relational database [OK]
Hint: Tables and SQL mean relational database [OK]
Common Mistakes:
Confusing NoSQL with relational because both store data
Thinking object-oriented databases use SQL
Assuming graph databases are relational
2. Which of the following is the correct way to describe a NoSQL database?
easy
A. Stores flexible data like documents or key-value pairs
B. Stores data only in tables with fixed schema
C. Stores data as objects matching programming languages
D. Uses only SQL for data queries
Solution
Step 1: Recall NoSQL database features
NoSQL databases store data flexibly, often as documents or key-value pairs.
Step 2: Eliminate incorrect options
They do not require fixed schemas or only tables, and do not rely solely on SQL.
Final Answer:
Stores flexible data like documents or key-value pairs -> Option A
Quick Check:
No fixed schema + flexible data = NoSQL [OK]
Hint: Flexible data storage means NoSQL [OK]
Common Mistakes:
Thinking NoSQL uses only tables
Confusing object-oriented with NoSQL
Assuming NoSQL requires SQL queries
3. Given the following description, which database type fits best? Data is stored as objects with properties and methods, similar to programming languages.
medium
A. Relational database
B. NoSQL database
C. Object-oriented database
D. Hierarchical database
Solution
Step 1: Analyze data storage style
The data is stored as objects with properties and methods, matching programming language objects.
Step 2: Match to database type
Object-oriented databases store data as objects, unlike relational or NoSQL databases.
Final Answer:
Object-oriented database -> Option C
Quick Check:
Objects with methods = Object-oriented database [OK]
Hint: Objects with methods mean object-oriented DB [OK]
Common Mistakes:
Confusing object-oriented with NoSQL
Thinking relational databases store objects
Assuming hierarchical is object-oriented
4. Identify the error in this statement: NoSQL databases always use SQL queries to retrieve data.
medium
A. No error, statement is correct
B. NoSQL databases do not use SQL queries
C. NoSQL databases only store data in tables
D. NoSQL databases are a type of relational database
Solution
Step 1: Understand NoSQL query methods
NoSQL databases typically use query methods other than SQL, like JSON queries or key-value lookups.
Step 2: Identify the error
The statement wrongly claims NoSQL always uses SQL, which is false.
Final Answer:
NoSQL databases do not use SQL queries -> Option B
Quick Check:
NoSQL ≠ SQL queries [OK]
Hint: NoSQL means no SQL queries [OK]
Common Mistakes:
Believing NoSQL uses SQL
Confusing NoSQL with relational
Thinking NoSQL stores only tables
5. A company wants to store user profiles with flexible fields that can change often, and also wants to store some complex objects with methods for processing. Which combination of databases should they use?
hard
A. A NoSQL database for flexible data and an object-oriented database for complex objects
B. Only a relational database
C. Only a NoSQL database
D. Only an object-oriented database
Solution
Step 1: Analyze data needs
Flexible fields suggest NoSQL for schema flexibility; complex objects with methods suggest object-oriented database.
Step 2: Choose suitable combination
Using both NoSQL and object-oriented databases fits the requirements best.
Final Answer:
A NoSQL database for flexible data and an object-oriented database for complex objects -> Option A