How would do this? Write a script that implements the following design: In the D
ID: 3811160 • Letter: H
Question
How would do this?
Write a script that implements the following design:
In the Downloads table, the user_id and product_id columns are the foreign keys.Create these tables in the ex schema. Create the sequences for the user_id, download_id, and product_id columns. Include a PL/SQL script to drop the table or sequence if it already exists. Include any indexes that you think are necessary.
Write a script that implements the following design: In the Downloads table, the user_id and product_id columns are the foreign keys. Create these tables in the ex schema. Create the sequences for the user_id, downloaded, and product_id columns. Include a PL/SQL script to drop the table or sequence if it already exists. Include any indexes that you think are necessary.Explanation / Answer
Script:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ex].[Products]') AND TYPE IN (N'U'))
DROP TABLE [ex].[Products]
CREATE TABLE [ex].[Products]
(
product_id iNT IDENTITY(1,1) Primary Key,
product_name NVARCHAR(500)
)
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ex].[users]') AND TYPE IN (N'U'))
DROP TABLE [ex].[users]
CREATE TABLE [ex].[users]
(
user_id iNT IDENTITY(1,1) Primary Key,
product_name NVARCHAR(500),
first_name NVARCHAR(500),
last_name NVARCHAR(500),
)
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ex].[downloads]') AND TYPE IN (N'U'))
DROP TABLE [ex].[downloads]
CREATE TABLE [ex].[downloads]
(
download_id iNT IDENTITY(1,1) Primary Key,
user_id int FOREIGN KEY REFERENCES [ex].[users](user_id),
download_date DATETIME,
file_name NVARCHAR(500),
product_id INT FOREIGN KEY REFERENCES [ex].[products](product_id)
)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.