Question

In: Computer Science

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:

  1. A Publisher table where each publisher is identified by an integer id and has a name (up to 40 characters). (1 mark)

  2. 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)

  3. An App table storing each app that is identified by a field called id that is an integer. Other attributes include name (string up to 40 characters), publisherId (integer), categoryId (integer), and description (string up to 255 characters). Make all foreign keys set to null on delete and no action (generate error) on update.

  4. A AppVersion table that stores each version of the app. The primary key is the appId and version (exactly 10 characters). Each release has a releaseDate (DATETIME), an integer rating, a price (up to 10 digits with 2 decimals), and a description (up to 500 characters). Make all foreign keys set to perform cascade on delete and cascade on update.

  5. A AppVersionReview table that stores ratings for each application version. The primary key is the appId, version, and reviewer (exactly 20 characters). There is also a reviewDate (DATETIME), rating (int), and review (up to 1000 characters). Make all foreign keys set to cascade on both update and delete. A value for the reviewDate field is always required.

Solutions

Expert Solution

Solution:

Syntax for creating a table in database is

create table tablename(column datatype, column datatype,....................)

1) create table Publisher(publisherId int, name varchar(40))

2) create table Category(categoryId int, name varchar(50), parentId int, Foreign Key(parentId))

3) create table App(Id int, name varchar(40), publisherId int, categoryId int, description varchar(255),

Constraint fk_ap_id

Foreign Key(publisherId, categoryId)

References Publisher(publisherId), Category(categoryId)

On Delete set NULL [ On Update { No Action } ] )

4) create table AppVersion(appId int Primary Key, version varchar(10), releaseDate Date, rating int, price decimal(10, 2), description varchar(500),

Constraint fk_appver_id

Foreign Key(appId)

References App(id)

On Delete set NULL [ On Update { Cascade } ] )

5) create table AppVersionReview(appId int Primary Key, version varchar(10), reviewer varchar(20), reviewDate Date NOT NULL, rating int, review varchar(1000),

Constraint fk_appver_rev_id

Foreign Key(appId)

References App(id)

On Delete set NULL [ On Update { Cascade } ] )


Related Solutions

1. write SQL statements to create the following two tables: a) Department table that contains the...
1. write SQL statements to create the following two tables: a) Department table that contains the following columns(dept_no,deptname,location) set the deptno to be the primary key. b) Employee table contains the following columns(emp_no,empname,deptno,salary)set the emp_no to be the primary key and dept_no to be the foreign key. 2. Write SQL statements to Insert the following 3 rows in Employee table:        (101,’Sami’,’D-101’,5000)        (102,’Yousef’,’D-101’,4000)        (103,’Sami’,’D-102’,7000) 3. Write SQL statements to Insert the following 3 rows in Department table:       ...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create SALESREP and CUSTOMER tables Create primary and foreign keys as appropriate. The custNo should use a surrogate key as the primary key with auto-increment increase the balance of the Gonzales account by $100 to a total of $450? Find an average customer balance Display the name of the sales representative and the name of the customer for each customer that has a balance greater...
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...
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”,...
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)
Using the HotelDB tables, provide the following result as a screen image. WRITE SQL to retrieve...
Using the HotelDB tables, provide the following result as a screen image. WRITE SQL to retrieve rows from any hotel with Family room types and price less than $150. use hoteldb; CREATE TABLE HOTEL ( hotelNo numeric primary key , name varchar(40) , address varchar(40) , city varchar(200) ); CREATE TABLE ROOM ( roomNo numeric Primary Key , hotelNo numeric References HOTEL , type varchar(20) , price dec(9,2) ); CREATE TABLE GUEST ( guestNo numeric primary key , name varchar(40)...
Homework: Populate Sales Order tables. Write SQL to : 1. insert 5 records in each table:...
Homework: Populate Sales Order tables. Write SQL to : 1. insert 5 records in each table: Market, Region, ProductFamily, Manager (all Managers must have different % commissions, Commission is an attribute of the Manger). 2. Insert 5 records in Agent using all Managers 3. Insert 15 records in Product using  all ProductFamily 4. Insert 15 records in Customer using various Regions and Markets 5. Insert 50 records in SalesOrder using various Customers, Products, Agents Notes : ALL the Names ( Description)...
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
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT