Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tasks Find * in the database exam _ data _ 2 0 2 3 _ 0 5 _ 2 9 . txt: , ( 3

Tasks
Find * in the database exam_data_2023_05_29.txt: ,(3 points)
the pair of products that generated the most revenue in the second quarter 2021. The solution is a-
view called'sell.
It-should-look'likef|
Check if your data is in the seller table.
The table - is in relation to the product * table.
Who'sold the same products'(at-least'one product) with'You'in'your birthday month (year'2021 and-
?
The solution is a view 'called'sellers. {
Create a tables 'as shown'in the picture and use (write) triggers for updates and for inserting data in -
tables:
bank account 2/****** Object: Table [dbo].[order] Script Date: 14.01.202417:47:55******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[order](
[id_order][int] IDENTITY(1,1) NOT NULL,
[id_product][int] NULL,
[order][varchar](50) NULL,
[order_date][date] NULL,
CONSTRAINT [PK_order] PRIMARY KEY CLUSTERED
(
[id_order] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[product] Script Date: 14.01.202417:47:55******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[product](
[id_product][int] IDENTITY(1,1) NOT NULL,
[product][varchar](50) NULL,
[price][float] NULL,
CONSTRAINT [PK_product] PRIMARY KEY CLUSTERED
(
[id_product] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[product_salesman] Script Date: 14.01.202417:47:55******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[product_salesman](
[id_product_salesman][int] IDENTITY(1,1) NOT NULL,
[id_salesman][int] NULL,
[id_product][int] NULL,
CONSTRAINT [PK_product_salesman_new] PRIMARY KEY CLUSTERED
(
[id_product_salesman] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[salesman] Script Date: 14.01.202417:47:55******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[salesman](
[id_salesman][int] IDENTITY(1,1) NOT NULL,
[surname][nvarchar](40) NULL,
[name][nvarchar](40) NULL,
[name2][nvarchar](40) NULL,
[id][nvarchar](6) NULL,
CONSTRAINT [PK_list_2024] PRIMARY KEY CLUSTERED
(
[id_salesman] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[order] ON
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (2,30, N'SO61269', CAST(N'2021-11-25' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (3,13, N'SO61269', CAST(N'2021-12-15' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (4,5, N'SO61270', CAST(N'2021-04-18' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (5,12, N'SO61271', CAST(N'2021-10-22' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (6,21, N'SO61271', CAST(N'2022-06-18' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (7,17, N'SO61272', CAST(N'2021-02-25' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (8,21, N'SO61272', CAST(N'2022-11-18' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (9,36, N'SO61273', CAST(N'2021-08-17' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (10,4, N'SO61274', CAST(N'2021-07-11' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (11,37, N'SO61274', CAST(N'2021-12-07' AS Date))
INSERT [dbo].[order]([id_order],[id_product],[order],[order_date]) VALUES (12,30, N'SO6127

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

Describe the uses of information gained from job analysis.

Answered: 1 week ago