If you need to store the following data in a relational database and MongoDB, how would you implement in each of them. List the design and commands to store these records in relational database (SQL query) and MongoDB separately.
{no:1,name:"ST",salary:2000,role:"OB"}
{no:2,name:"MSD",salary:1500,role:"WK"}
{no:3,name:"YS",salary:1000,role:"ALR"},
1). ANSWER :
GIVENTHAT :
Relational database, MySQL
Precondition: Create and use database
Step 1: Creation of table "jobs"
create table jobs(no int primary key, name varchar(100), salary int, role varchar(100));
Step 2: Insertion into table "jobs"
insert into jobs values(1,"ST",2000,"OB");
insert into jobs values(2,"MSD",1500,"WK");
insert into jobs values(3, "YS", 1000, "ALR");
MongoDB
Precondition: Create and use database
Step 1: Creation of collection "jobs"
db.createCollection("jobs")
Step 2: Insertion into collection "jobs"
db.jobs.insert([
{no:1,name:"ST",salary:2000,role:"OB" },
{no:2,name:"MSD",salary:1500,role:"WK"},
{no:3,name:"YS",salary:1000,role:"ALR"}
])
Get Answers For Free
Most questions answered within 1 hours.