Assignment on Script to Create Database
VerifiedAdded on  2022/09/16
|20
|5498
|21
Assignment
AI Summary
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/ca9d5290-552b-4990-b38f-143db874ae33-page-1.webp)
Two tasks have been completed. Task 4 and Task 6
Task 4
-- SCRIPT TO CREATE DATABASE, TABLES, ROWS
/****** Object: Table [dbo].[Agent] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Agent]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Agent]
GO
/****** Object: Table [dbo].[Booking] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Booking]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Booking]
GO
/****** Object: Table [dbo].[Checkout] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Checkout]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Checkout]
GO
/****** Object: Table [dbo].[Customer] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Customer]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Customer]
GO
/****** Object: Table [dbo].[Hotel] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Hotel]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Hotel]
GO
/****** Object: Table [dbo].[Room] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Room]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Room]
GO
/****** Object: Table [dbo].[Time] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Time]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Time]
GO
/****** Object: Table [dbo].[Time] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Task 4
-- SCRIPT TO CREATE DATABASE, TABLES, ROWS
/****** Object: Table [dbo].[Agent] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Agent]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Agent]
GO
/****** Object: Table [dbo].[Booking] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Booking]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Booking]
GO
/****** Object: Table [dbo].[Checkout] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Checkout]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Checkout]
GO
/****** Object: Table [dbo].[Customer] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Customer]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Customer]
GO
/****** Object: Table [dbo].[Hotel] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Hotel]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Hotel]
GO
/****** Object: Table [dbo].[Room] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Room]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Room]
GO
/****** Object: Table [dbo].[Time] Script Date: 04/09/2018 22:39:00 ******/
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Time]')
AND type IN (N'U')
)
DROP TABLE [dbo].[Time]
GO
/****** Object: Table [dbo].[Time] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/e9b06cdd-9ea2-44cd-a26e-f7eaed83b6cf-page-2.webp)
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Time]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Time] (
[time_id] [int] NOT NULL
,[day] [int] NULL
,[month] [int] NULL
,[year] [int] NULL
,CONSTRAINT [PK_Time] PRIMARY KEY CLUSTERED ([time_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
1
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
2
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
3
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
4
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Time]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Time] (
[time_id] [int] NOT NULL
,[day] [int] NULL
,[month] [int] NULL
,[year] [int] NULL
,CONSTRAINT [PK_Time] PRIMARY KEY CLUSTERED ([time_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
1
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
2
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
3
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
4
,1
,2
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/941bcf42-0e54-4b32-9368-e6940e6dd49c-page-3.webp)
)
VALUES (
5
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
6
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
7
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
8
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
9
,1
,1
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
10
,1
,1
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
11
VALUES (
5
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
6
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
7
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
8
,1
,1
,2018
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
9
,1
,1
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
10
,1
,1
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
11
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/9df4a89e-ac32-407d-bf90-e0cfcba2eae6-page-4.webp)
,1
,1
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
12
,1
,2
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
13
,1
,1
,2017
)
/****** Object: Table [dbo].[Room] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Room]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Room] (
[room_id] [int] NOT NULL
,[hotel_id] [int] NOT NULL
,[no_of_beds] [int] NULL
,[tv] [bit] NULL
,[whirlpool_bath] [bit] NULL
,[promotion] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[rate] [decimal](18, 2) NULL
,CONSTRAINT [PK_Room] PRIMARY KEY CLUSTERED ([room_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
1
,5
,NULL
,NULL
,NULL
,NULL
,NULL
,1
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
12
,1
,2
,2017
)
INSERT [dbo].[Time] (
[time_id]
,[day]
,[month]
,[year]
)
VALUES (
13
,1
,1
,2017
)
/****** Object: Table [dbo].[Room] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Room]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Room] (
[room_id] [int] NOT NULL
,[hotel_id] [int] NOT NULL
,[no_of_beds] [int] NULL
,[tv] [bit] NULL
,[whirlpool_bath] [bit] NULL
,[promotion] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[rate] [decimal](18, 2) NULL
,CONSTRAINT [PK_Room] PRIMARY KEY CLUSTERED ([room_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
1
,5
,NULL
,NULL
,NULL
,NULL
,NULL
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/06c8e9ca-c283-46d2-9c08-5dde7e33372e-page-5.webp)
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
2
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
3
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
4
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
5
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
2
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
3
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
4
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
5
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/d7f7bf8b-7808-45a2-9158-a9de4e4413f0-page-6.webp)
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
6
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
7
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
8
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
9
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
6
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
7
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
8
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
9
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/c12e42ab-d34a-4de9-a6d1-834e6480c03b-page-7.webp)
)
VALUES (
10
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
11
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
12
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
13
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
/****** Object: Table [dbo].[Hotel] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Hotel]')
AND type IN (N'U')
)
VALUES (
10
,1
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
11
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
12
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
INSERT [dbo].[Room] (
[room_id]
,[hotel_id]
,[no_of_beds]
,[tv]
,[whirlpool_bath]
,[promotion]
,[rate]
)
VALUES (
13
,5
,NULL
,NULL
,NULL
,NULL
,NULL
)
/****** Object: Table [dbo].[Hotel] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Hotel]')
AND type IN (N'U')
)
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/2b92ab71-0b04-4b96-8974-6a9a858b169b-page-8.webp)
BEGIN
CREATE TABLE [dbo].[Hotel] (
[hotel_id] [int] NOT NULL
,[city] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[province] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[country] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[category] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,CONSTRAINT [PK_Hotel] PRIMARY KEY CLUSTERED ([hotel_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
1
,N'calcutta '
,NULL
,N'india '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
2
,N'calcutta '
,NULL
,N'india '
,N'2 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
3
,N'delhi '
,NULL
,N'india '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
4
,N'mumbai '
,NULL
,N'india '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
CREATE TABLE [dbo].[Hotel] (
[hotel_id] [int] NOT NULL
,[city] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[province] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[country] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,[category] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,CONSTRAINT [PK_Hotel] PRIMARY KEY CLUSTERED ([hotel_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
1
,N'calcutta '
,NULL
,N'india '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
2
,N'calcutta '
,NULL
,N'india '
,N'2 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
3
,N'delhi '
,NULL
,N'india '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
4
,N'mumbai '
,NULL
,N'india '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/0378174e-b97e-46b0-9b7a-af4efc1a8c04-page-9.webp)
,[province]
,[country]
,[category]
)
VALUES (
5
,NULL
,NULL
,N'brazil '
,N'1 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
6
,NULL
,NULL
,N'brazil '
,N'2 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
7
,NULL
,NULL
,N'brazil '
,N'3 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
8
,NULL
,NULL
,N'brazil '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
9
,NULL
,NULL
,N'albania '
,N'1 '
)
/****** Object: Table [dbo].[Customer] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
,[country]
,[category]
)
VALUES (
5
,NULL
,NULL
,N'brazil '
,N'1 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
6
,NULL
,NULL
,N'brazil '
,N'2 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
7
,NULL
,NULL
,N'brazil '
,N'3 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
8
,NULL
,NULL
,N'brazil '
,N'4 '
)
INSERT [dbo].[Hotel] (
[hotel_id]
,[city]
,[province]
,[country]
,[category]
)
VALUES (
9
,NULL
,NULL
,N'albania '
,N'1 '
)
/****** Object: Table [dbo].[Customer] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/f6ff93c3-9908-4a90-853e-e912fb1c9e45-page-10.webp)
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Customer]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Customer] (
[customer_id] [int] NOT NULL
,[name] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED ([customer_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
1
,N'a '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
2
,N'b '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
3
,N'c '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
4
,N'd '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
5
,N'e '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
6
,N'f '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
7
,N'g '
)
WHERE object_id = OBJECT_ID(N'[dbo].[Customer]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Customer] (
[customer_id] [int] NOT NULL
,[name] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED ([customer_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
1
,N'a '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
2
,N'b '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
3
,N'c '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
4
,N'd '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
5
,N'e '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
6
,N'f '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
7
,N'g '
)
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/81afda45-ec4a-492b-9295-20ba3a299b3b-page-11.webp)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
8
,N'h '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
9
,N'i '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
10
,N'j '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
11
,N'k '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
12
,N'l '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
13
,N'm '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
14
,N'n '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
15
,N'o '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
16
,N'p '
)
[customer_id]
,[name]
)
VALUES (
8
,N'h '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
9
,N'i '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
10
,N'j '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
11
,N'k '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
12
,N'l '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
13
,N'm '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
14
,N'n '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
15
,N'o '
)
INSERT [dbo].[Customer] (
[customer_id]
,[name]
)
VALUES (
16
,N'p '
)
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/0f17eb6a-0905-4590-876f-f6bc1938b68c-page-12.webp)
/****** Object: Table [dbo].[Checkout] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Checkout]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Checkout] (
[checkout_id] [int] NOT NULL
,[room_id] [int] NULL
,[hotel_id] [int] NULL
,[customer_id] [int] NULL
,[time_id] [int] NULL
,[revenue] [decimal](18, 2) NULL
,CONSTRAINT [PK_Checkout] PRIMARY KEY CLUSTERED ([checkout_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
1
,1
,1
,1
,1
,CAST(500.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
2
,2
,1
,2
,2
,CAST(600.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
3
,3
,1
,3
,3
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Checkout]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Checkout] (
[checkout_id] [int] NOT NULL
,[room_id] [int] NULL
,[hotel_id] [int] NULL
,[customer_id] [int] NULL
,[time_id] [int] NULL
,[revenue] [decimal](18, 2) NULL
,CONSTRAINT [PK_Checkout] PRIMARY KEY CLUSTERED ([checkout_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
1
,1
,1
,1
,1
,CAST(500.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
2
,2
,1
,2
,2
,CAST(600.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
3
,3
,1
,3
,3
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/b24dbfe4-80b1-405e-83f7-c9bd692ac258-page-13.webp)
,CAST(700.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
4
,4
,1
,4
,4
,CAST(800.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
5
,5
,1
,5
,5
,CAST(900.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
6
,6
,1
,6
,6
,CAST(400.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
7
,7
,1
,7
,7
,CAST(500.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
8
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
4
,4
,1
,4
,4
,CAST(800.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
5
,5
,1
,5
,5
,CAST(900.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
6
,6
,1
,6
,6
,CAST(400.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
7
,7
,1
,7
,7
,CAST(500.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
8
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/649a79f1-1a13-4fe8-92e2-cb5bbf7ffdf4-page-14.webp)
,8
,1
,8
,8
,CAST(800.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
9
,9
,5
,9
,9
,CAST(900.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
10
,10
,5
,10
,10
,CAST(900.00 AS DECIMAL(18, 2))
)
/****** Object: Table [dbo].[Booking] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Booking]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Booking] (
[booking_id] [int] NOT NULL
,[customer_id] [int] NULL
,[room_id] [int] NULL
,[hotel_id] [int] NULL
,[agent_id] [int] NULL
,[time_id] [int] NULL
,[revenue] [decimal](18, 2) NULL
,CONSTRAINT [PK_Booking] PRIMARY KEY CLUSTERED ([booking_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,1
,8
,8
,CAST(800.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
9
,9
,5
,9
,9
,CAST(900.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Checkout] (
[checkout_id]
,[room_id]
,[hotel_id]
,[customer_id]
,[time_id]
,[revenue]
)
VALUES (
10
,10
,5
,10
,10
,CAST(900.00 AS DECIMAL(18, 2))
)
/****** Object: Table [dbo].[Booking] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Booking]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Booking] (
[booking_id] [int] NOT NULL
,[customer_id] [int] NULL
,[room_id] [int] NULL
,[hotel_id] [int] NULL
,[agent_id] [int] NULL
,[time_id] [int] NULL
,[revenue] [decimal](18, 2) NULL
,CONSTRAINT [PK_Booking] PRIMARY KEY CLUSTERED ([booking_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/8693589c-4121-4fe8-8f32-56052bcef68c-page-15.webp)
,[revenue]
)
VALUES (
1
,1
,1
,1
,NULL
,1
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
2
,2
,2
,1
,NULL
,2
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
3
,3
,3
,1
,NULL
,3
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
4
,4
,4
,1
,NULL
,4
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
5
,5
)
VALUES (
1
,1
,1
,1
,NULL
,1
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
2
,2
,2
,1
,NULL
,2
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
3
,3
,3
,1
,NULL
,3
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
4
,4
,4
,1
,NULL
,4
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
5
,5
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/944d0bb3-f044-4843-bf16-4639fdb2c88a-page-16.webp)
,5
,1
,NULL
,5
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
6
,6
,6
,1
,NULL
,6
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
7
,7
,7
,1
,NULL
,7
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
8
,8
,8
,1
,NULL
,8
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
9
,9
,9
,5
,NULL
,9
,CAST(100.00 AS DECIMAL(18, 2))
,1
,NULL
,5
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
6
,6
,6
,1
,NULL
,6
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
7
,7
,7
,1
,NULL
,7
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
8
,8
,8
,1
,NULL
,8
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
9
,9
,9
,5
,NULL
,9
,CAST(100.00 AS DECIMAL(18, 2))
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/bcd31619-6365-4b59-a21c-4a7dafab12df-page-17.webp)
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
10
,10
,10
,5
,NULL
,10
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
11
,11
,11
,5
,NULL
,11
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
12
,12
,12
,5
,NULL
,12
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
13
,13
,13
,5
,NULL
,13
,CAST(100.00 AS DECIMAL(18, 2))
)
/****** Object: Table [dbo].[Agent] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
10
,10
,10
,5
,NULL
,10
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
11
,11
,11
,5
,NULL
,11
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
12
,12
,12
,5
,NULL
,12
,CAST(100.00 AS DECIMAL(18, 2))
)
INSERT [dbo].[Booking] (
[booking_id]
,[customer_id]
,[room_id]
,[hotel_id]
,[agent_id]
,[time_id]
,[revenue]
)
VALUES (
13
,13
,13
,5
,NULL
,13
,CAST(100.00 AS DECIMAL(18, 2))
)
/****** Object: Table [dbo].[Agent] Script Date: 04/09/2018 22:39:00 ******/
SET ANSI_NULLS ON
GO
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/f078e2df-b9b9-4311-910c-3b84af7e3164-page-18.webp)
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Agent]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Agent] (
[agent_id] [int] NOT NULL
,[name] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,CONSTRAINT [PK_Agent] PRIMARY KEY CLUSTERED ([agent_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
TASK 6
--Query1
SELECT T1.country
,T1.year
,T1.month
,T1.booked
,T2.checkedout
,(
(
SELECT count(*)
FROM room
LEFT JOIN booking ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
HAVING t1.country = hotel.country
) - (T1.booked + T2.checkedout)
) AS 'Free'
FROM (
SELECT hotel.country
,TIME.year
,TIME.month
,COUNT(booking.room_id) AS booked
FROM booking
LEFT JOIN room ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T1
INNER JOIN (
SELECT hotel.country
,TIME.year
,TIME.month
,COUNT(checkout.room_id) AS checkedout
FROM checkout
LEFT JOIN room ON room.room_id = checkout.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON checkout.time_id = TIME.time_id
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T2 ON T1.country = T2.country
AND T1.year = T2.year
AND T1.month = T2.month
--Query 2
SELECT T1.country
,T1.year
,
--T1.month ,
GO
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Agent]')
AND type IN (N'U')
)
BEGIN
CREATE TABLE [dbo].[Agent] (
[agent_id] [int] NOT NULL
,[name] [nchar](10) COLLATE Latin1_General_CI_AI NULL
,CONSTRAINT [PK_Agent] PRIMARY KEY CLUSTERED ([agent_id] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
)
)
END
GO
TASK 6
--Query1
SELECT T1.country
,T1.year
,T1.month
,T1.booked
,T2.checkedout
,(
(
SELECT count(*)
FROM room
LEFT JOIN booking ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
HAVING t1.country = hotel.country
) - (T1.booked + T2.checkedout)
) AS 'Free'
FROM (
SELECT hotel.country
,TIME.year
,TIME.month
,COUNT(booking.room_id) AS booked
FROM booking
LEFT JOIN room ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T1
INNER JOIN (
SELECT hotel.country
,TIME.year
,TIME.month
,COUNT(checkout.room_id) AS checkedout
FROM checkout
LEFT JOIN room ON room.room_id = checkout.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON checkout.time_id = TIME.time_id
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T2 ON T1.country = T2.country
AND T1.year = T2.year
AND T1.month = T2.month
--Query 2
SELECT T1.country
,T1.year
,
--T1.month ,
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/26f68edd-7b2b-4c5b-8ce8-0ec1702d9828-page-19.webp)
T1.booked
,T2.checkedout
,(
(
SELECT count(*)
FROM room
LEFT JOIN booking ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
HAVING t1.country = hotel.country
) - (T1.booked + T2.checkedout)
) AS 'Free'
,booking_revenue
,checkedout_revenue
,booking_revenue + checkedout_revenue AS 'cumulative_revenue'
,T2.checkedout_revenue / T1.booking_revenue AS CheckedOutRatio
,DENSE_RANK() OVER (
ORDER BY T2.checkedout_revenue / T1.booking_revenue
) AS RankForTheYear
FROM (
SELECT hotel.country
,
--time.month,
TIME.year
,COUNT(booking.room_id) AS booked
,SUM(booking.revenue) AS booking_revenue
FROM booking
LEFT JOIN room ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
,
--time.month,
TIME.year
) AS T1
INNER JOIN (
SELECT hotel.country
,TIME.year
,
--time.month,
COUNT(checkout.room_id) AS checkedout
,SUM(checkout.revenue) AS checkedout_revenue
FROM checkout
LEFT JOIN room ON room.room_id = checkout.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON checkout.time_id = TIME.time_id
GROUP BY hotel.country
,
--time.month,
TIME.year
) AS T2 ON T1.country = T2.country
AND T1.year = T2.year
--AND T1.month=T2.month
ORDER BY year DESC
,CheckedOutRatio DESC
,RankForTheYear ASC
--Query3
SELECT T1.country
,T1.year
,T1.month
,T1.booked
,T2.checkedout
,(
(
SELECT count(*)
FROM room
LEFT JOIN booking ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
HAVING t1.country = hotel.country
) - (T1.booked + T2.checkedout)
) AS 'Free'
,booking_revenue
,checkedout_revenue
,booking_revenue + checkedout_revenue AS 'cumulative_revenue'
FROM (
SELECT hotel.country
,TIME.year
,TIME.month
,T2.checkedout
,(
(
SELECT count(*)
FROM room
LEFT JOIN booking ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
HAVING t1.country = hotel.country
) - (T1.booked + T2.checkedout)
) AS 'Free'
,booking_revenue
,checkedout_revenue
,booking_revenue + checkedout_revenue AS 'cumulative_revenue'
,T2.checkedout_revenue / T1.booking_revenue AS CheckedOutRatio
,DENSE_RANK() OVER (
ORDER BY T2.checkedout_revenue / T1.booking_revenue
) AS RankForTheYear
FROM (
SELECT hotel.country
,
--time.month,
TIME.year
,COUNT(booking.room_id) AS booked
,SUM(booking.revenue) AS booking_revenue
FROM booking
LEFT JOIN room ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
,
--time.month,
TIME.year
) AS T1
INNER JOIN (
SELECT hotel.country
,TIME.year
,
--time.month,
COUNT(checkout.room_id) AS checkedout
,SUM(checkout.revenue) AS checkedout_revenue
FROM checkout
LEFT JOIN room ON room.room_id = checkout.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON checkout.time_id = TIME.time_id
GROUP BY hotel.country
,
--time.month,
TIME.year
) AS T2 ON T1.country = T2.country
AND T1.year = T2.year
--AND T1.month=T2.month
ORDER BY year DESC
,CheckedOutRatio DESC
,RankForTheYear ASC
--Query3
SELECT T1.country
,T1.year
,T1.month
,T1.booked
,T2.checkedout
,(
(
SELECT count(*)
FROM room
LEFT JOIN booking ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
GROUP BY hotel.country
HAVING t1.country = hotel.country
) - (T1.booked + T2.checkedout)
) AS 'Free'
,booking_revenue
,checkedout_revenue
,booking_revenue + checkedout_revenue AS 'cumulative_revenue'
FROM (
SELECT hotel.country
,TIME.year
,TIME.month
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
![Document Page](https://desklib.com/media/document/docfile/pages/script-to-create-database-new/2024/09/15/9314f53d-a076-4e15-aaed-04d5bc73c41e-page-20.webp)
,COUNT(booking.room_id) AS booked
,SUM(booking.revenue) AS booking_revenue
FROM booking
LEFT JOIN room ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
WHERE hotel.category = 4
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T1
INNER JOIN (
SELECT hotel.country
,TIME.year
,TIME.month
,COUNT(checkout.room_id) AS checkedout
,SUM(checkout.revenue) AS checkedout_revenue
FROM checkout
LEFT JOIN room ON room.room_id = checkout.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON checkout.time_id = TIME.time_id
WHERE hotel.category = 4
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T2 ON T1.country = T2.country
AND T1.year = T2.year
AND T1.month = T2.month
,SUM(booking.revenue) AS booking_revenue
FROM booking
LEFT JOIN room ON room.room_id = booking.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON booking.time_id = TIME.time_id
WHERE hotel.category = 4
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T1
INNER JOIN (
SELECT hotel.country
,TIME.year
,TIME.month
,COUNT(checkout.room_id) AS checkedout
,SUM(checkout.revenue) AS checkedout_revenue
FROM checkout
LEFT JOIN room ON room.room_id = checkout.room_id
LEFT JOIN hotel ON room.hotel_id = hotel.hotel_id
LEFT JOIN TIME ON checkout.time_id = TIME.time_id
WHERE hotel.category = 4
GROUP BY hotel.country
,TIME.year
,TIME.month
) AS T2 ON T1.country = T2.country
AND T1.year = T2.year
AND T1.month = T2.month
1 out of 20
Related Documents
![[object Object]](/_next/image/?url=%2F_next%2Fstatic%2Fmedia%2Flogo.6d15ce61.png&w=640&q=75)
Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024  |  Zucol Services PVT LTD  |  All rights reserved.