Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How might we specify the following SQL in MongoDB ? CREATE TABLE course ( code CHAR ( 3 ) PRIMARY KEY, name VARCHAR ( 3

How might we specify the following SQL in MongoDB ?
CREATE TABLE course (
code CHAR(3) PRIMARY KEY,
name VARCHAR(30) NOT NULL,
credits TINYINT NOT NULL
);
INSERT INTO course (`code`,`name`,`credits`)
VALUES
('WSD', 'Web Systems Development', 75),
('DDM', 'Database Design & Management', 100),
('NSF', 'Network Security & Forensics', 75);
CREATE TABLE Module (
code CHAR(2) PRIMARY KEY,
name VARCHAR(30) NOT NULL,
cost DECIMAL(8,2) NOT NULL,
credits TINYINT NOT NULL,
course_code CHAR(3) NOT NULL,
CONSTRAINT fk_course_code
FOREIGN KEY (course_code)
REFERENCES course (code)
ON UPDATE CASCADE
ON DELETE RESTRICT
);
INSERT INTO module (`code`,`name`,`cost`,`credits`,`course_code`)
VALUES
('A2', 'ASP.NET', 250,25,'WSD'),
('A3','PHP',250,25,'WSD'),
('A4', 'JavaFX', 350,25,'WSD'),
('B2', 'Oracle', 750,50,'DDM'),
('B3','SQLS',750,50,'DDM'),
('C2', 'Law', 250,25,'NSF'),
('C3', 'Forensics', 350,25,'NSF'),
('C4', 'Networks', 250,25,'NSF');

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions