Question

In: Computer Science

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”, “Exam_1”, “Exam_2”, etc)

•A StudentExamGrade entity ( bannerId, crnNumber, examId, grade)

2. Insert 4 students, 3 exams_table, 6 courses.

3. Insert for each student 2 ex_am_  grades for 2 different courses.

4. Run a SQL query to view all the data inserted in all 4 tables created.

Solutions

Expert Solution

STUDENT TABLE:

create table students (bannerID int NOT NULL PRMARY KEY, firstname varchar(15), lastname varchar(15), dateofbirth DATE);

COURSE TABLE:

create table courses(crnNumber int NOT NULL PRIMARY KEY, coursename varchar(20), ofcredits int);

EXAMINATION TABLE:

create table exams (examId int NOT NULL PRIMARY KEY, exam_type varchar (15), exam_date DATE);

StudentExamGrade TABLE:

create table StudentExamGrade(bannerId int FOREIGN KEY REFERENCES students(bannerID), crnNumber int FOREIGN KEY REFERENCES courses(crnNumber), examId int FOREIGN KEY REFERENCES exams(examId), grade CHAR(3));

Insertion in student table:

Insert into students values ('3161116', 'dee', 'sree', '1999-12-28');

Insert into students values ('3161117', 'meen', 'tkon', '1999-11-18');

Insert into students values ('3161118', 'balvee', 'chow', '1998-10-26');

Insert into students values ('3161119', 'vitvar', 'dant', '1998-12-22');

Insertion into course table:

Insert into courses values ('12301', 'Ethics', '10');

Insert into courses values ('12302', 'DLD', '10');

Insert into courses values ('12303', 'Robotics', '10');

Insert into courses values ('12304', 'DataStructures', '10');

Insert into courses values ('12305', 'BigData', '10');

Insert into courses values ('12306', 'Thermodynamics', '10');

Insertion into Examination table:

Insert into exams values ('101', 'Midterm', '2020-10-29');

Insert into exams values ('112', 'Fina;', '2020-11-30');

Insert into exams values ('201', 'Exam_1', '2020-10-30');

Insertion into  StudentExamGrade table:

Insert into  StudentExamGrade values ('3161116', '12302', '101', 'A');

Insert into  StudentExamGrade values ('3161116', '12303', '101', 'B');

Insert into  StudentExamGrade values ('3161117', '12302', '112', 'A');

Insert into  StudentExamGrade values ('3161117', '12301', '101', 'A');

Insert into  StudentExamGrade values ('3161118', '12304', '101', 'B');

Insert into  StudentExamGrade values ('3161118', '12305', '201', 'C');

Insert into  StudentExamGrade values ('3161116', '12303', '101', 'D');

Insert into  StudentExamGrade values ('3161116', '12306', '101', 'A');

SQL query to view all the data inserted in all 4 tables created:

  • select * from students;
  • select * from courses;
  • select * from exams;
  • select * from StudentExamGrade;

All the above queries will excute properly. I have followed every instruction and answered the given question

Please give upvote

For any queries please do comment


Related Solutions

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...
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)
Which of the following represent entities for this scenario.
Garden Glory is a company that provides yard maintenance services to its customers. Garden Glory offers many types of services such as grass cutting, shrubby maintenance, flowering planting, trimming, etc. Many of its customers have multiple properties [houses, office buildings, apartment complexes] that require gardening and lawn maintenance services. Garden Glory wants to maintain data on customers, properties, services offered and also track services provided. For services provided, they want to know what property, who that property belongs to and...
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
Create first draft for online shopping database (SQL): Things to do: Identify the entities Identify the...
Create first draft for online shopping database (SQL): Things to do: Identify the entities Identify the attributes Constraints Relations First Normal form Second Normal Form Third Normal Form Test Query to: Add a new item as a seller Query for total number of sold item in past month Query for total income in US DOLLARS
Use the SQL Developer to create the four tables EMP, DEPT, PROJ, EMP_PROJ with the appropriate...
Use the SQL Developer to create the four tables EMP, DEPT, PROJ, EMP_PROJ with the appropriate constraints except FOREIGN KEY constraints. For filename, use CREATE.sql accordingly. Import data from the csv files to EMP, DEPT, and PROJ tables. Check that all data for EMP, DEPT, and PROJ tables has been imported. __________________________ employees.csv empNo,fname,lname,address,sex,salary,position,deptNo 1000,Steven,King,"731 Fondren, Houston, TX",M,30000,Programmer,60 1007,Diana,Lorentz,"638 Voss, Bellaire, TX",F,24000,Clerk,20 2002,Pat,Fay,"3321 Castle, Spring, TX",F,15000,Sales Representative,80 1760,Jonathan,Taylor,"561 Rice, Houston, TX",M,60000,Manager,20 1740,Ellen,Abel,"890 Stone, Houston, TX",F,65000,Manager,60 2060,William,Gietz,"450 Berry, Bellaire, TX",M,65000,Manager,80 2000,Jennifer,Whalen,"980...
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.
Flag Create a database for PAINTER and PAINTING entities/tables; Decide on your own what will be...
Flag Create a database for PAINTER and PAINTING entities/tables; Decide on your own what will be the attributes of PAINTER and PAINTING tables; Insert at least 5 records on each table Deliverables: Screenshot of PAINTER and PAINTING table structures using the describe command Screenshot of PAINTER and PAINTING table records/entries using select command.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT