Question

In: Computer Science

Develop the SQL scripts that will create the tables and enforce all the appropriate constraints •...

Develop the SQL scripts that will create the tables and enforce all the appropriate

constraints

• Develop sample SQL scripts that will insert the data to the database (one row in each

table)

• Convert at least 2 entities to MongoDB Collections. Write the scripts that will Create the

collection(s)

Solutions

Expert Solution

consider a table containing records of a University:

Student Student id Subject Faculty/Instructor
Alex 1 Accountancy Robert
Bob 2 Numerology Franklin
Charlie 3 Anthropology Albert
David 4 Computer Science Ronald

To create this Table, the folloowing SQL statements are used:

CREATE TABLE records(Student varchar(20),Student-id number(10),Subject varchar(100),Faculty varchar((20))

Now, an empty table with Columns Student,Student-id,Subject,Faculty are created.

Then,to insert rows into the table with SQL queries, the following SQL statements are used:

INSERT into records(Student,Student-id,Subject,Faculty) values('Alex',1,'Accountancy','Robert');

INSERT into records(Student,Student-id,Subject,Faculty) values('Bob',2,'Numerology','Franklin');

INSERT into records(Student,Student-id,Subject,Faculty) values('Charlie',3,'Anthropology','Albert');

INSERT into records(Student,Student-id,Subject,Faculty) values('David',4,'Computer Science','Ronald');

TO Create Collections in MongoDB, we can use the following lines of code:

db.records.insertOne({ Student:"Alex",Student-id:1,Subject:"Accountancy",Faculty:"Robert"})

db.records.insertOne({ Student:"Bob",Student-id:2,Subject:"Numerology",Faculty:"Franlin"})

db.records.insertOne({ Student:"Charlie",Student-id:3,Subject:"Anthropology",Faculty:"Albert"})

db.records.insertOne({ Student:"David",Student-id:4,Subject:"Computer Science",Faculty:"Ronald"})

db.createCollections("records")


Related Solutions

Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns 2.Alter the tables to add the columns 3.Alter the tables to create the primary and foreign keys
Write the SQL DDL to create the following 5 tables for an App store: Publisher, Category,...
Write the SQL DDL to create the following 5 tables for an App store: Publisher, Category, App, AppVersion, AppVersionReview: A Publisher table where each publisher is identified by an integer id and has a name (up to 40 characters). (1 mark) A Category table where each category has an id (integer), a name (up to 50 characters), and a parentId to identify its parent category. The parentId should be a foreign key to the Category table. (1.5 marks) An App...
SQL code Create entities (tables) to represent the following ternary relationship. Note that we are not...
SQL code Create entities (tables) to represent the following ternary relationship. Note that we are not storing all the required information in these entities to simplify it. The underlined attributes are the primary keys. Don’t forget to set the constraints for primary and foreign keys: •A student entity ( bannerId, first name, last name, date of birth) •A course entity ( crnNumber, course name, # of credits) •An examination entity ( examId, exam_type, exam_date). (exam types can be “Midterm”, “Final”,...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
What are the keywords available in MS Access to use in SQL queries to enforce these...
What are the keywords available in MS Access to use in SQL queries to enforce these data integrity constraints? Discuss these with proper SQL queries.
. Please write the SQL statements required to create the following relations, including appropriate versions of...
. Please write the SQL statements required to create the following relations, including appropriate versions of all primary and foreign key integrity constraints. (10 points) Books (isbn:CHAR(10), title: CHAR(20), author: CHAR(80), qty_in_stock: INTEGER, price: REAL, year_published: INTEGER) Customers (cid:INTEGER, cname: CHAR(80), address: CHAR(200)) Orders (ordernum:INTEGER, cid:INTEGER, order_date: DATE, cardnum:CHAR(16)) Orderlists (ordernum:INTEGER, isbn:CHAR(10), qty:INTEGER, ship_date:DATE)
Please create the following tables for a tool rental database with appropriate primary keys & foreign...
Please create the following tables for a tool rental database with appropriate primary keys & foreign keys. Assumptions: 1. Each tool belongs to a category. 2. Each category may have a parent category but the parent category should not have a parent category (so at most two levels). E.g., a Tool A belongs to the electric mower, and electric mowers belong to mowers. Mower has no parent category. 3. Each tool can be rented at different time units. The typical...
Need SQL Tables Final Project should be included ER, NER, Table diagrams and SQL statements. The...
Need SQL Tables Final Project should be included ER, NER, Table diagrams and SQL statements. The final project is about developing an auction Web site. The details are as follows: BA is an online auction Web site. People can buy and sell items in this Web site. Buyers are people who like to buy items, and sellers are people who like to sell items. •Each seller can sell items. •Each item has a bidding start time, an end time, and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT