Skip to content

Instantly share code, notes, and snippets.

@l3ngli
Created January 27, 2026 08:04
Show Gist options
  • Select an option

  • Save l3ngli/e891227efe236be6c1767323f8582f5c to your computer and use it in GitHub Desktop.

Select an option

Save l3ngli/e891227efe236be6c1767323f8582f5c to your computer and use it in GitHub Desktop.
ДЗ по БД 1
USE [master]
GO
/****** Object: Database [ProductStore] Script Date: 27.01.2026 09:58:46 ******/
CREATE DATABASE [ProductStore]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'ProductStore', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL17.SQLEXPRESS\MSSQL\DATA\ProductStore.mdf' , SIZE = 15360KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'ProductStore_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL17.SQLEXPRESS\MSSQL\DATA\ProductStore_log.ldf' , SIZE = 5120KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
WITH CATALOG_COLLATION = DATABASE_DEFAULT, LEDGER = OFF
GO
ALTER DATABASE [ProductStore] SET COMPATIBILITY_LEVEL = 170
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [ProductStore].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [ProductStore] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [ProductStore] SET ANSI_NULLS OFF
GO
ALTER DATABASE [ProductStore] SET ANSI_PADDING OFF
GO
ALTER DATABASE [ProductStore] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [ProductStore] SET ARITHABORT OFF
GO
ALTER DATABASE [ProductStore] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [ProductStore] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [ProductStore] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [ProductStore] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [ProductStore] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [ProductStore] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [ProductStore] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [ProductStore] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [ProductStore] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [ProductStore] SET DISABLE_BROKER
GO
ALTER DATABASE [ProductStore] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [ProductStore] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [ProductStore] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [ProductStore] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [ProductStore] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [ProductStore] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [ProductStore] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [ProductStore] SET RECOVERY SIMPLE
GO
ALTER DATABASE [ProductStore] SET MULTI_USER
GO
ALTER DATABASE [ProductStore] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [ProductStore] SET DB_CHAINING OFF
GO
ALTER DATABASE [ProductStore] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [ProductStore] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [ProductStore] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [ProductStore] SET ACCELERATED_DATABASE_RECOVERY = OFF
GO
ALTER DATABASE [ProductStore] SET OPTIMIZED_LOCKING = OFF
GO
ALTER DATABASE [ProductStore] SET QUERY_STORE = ON
GO
ALTER DATABASE [ProductStore] SET QUERY_STORE (OPERATION_MODE = READ_WRITE, CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 30), DATA_FLUSH_INTERVAL_SECONDS = 900, INTERVAL_LENGTH_MINUTES = 60, MAX_STORAGE_SIZE_MB = 1000, QUERY_CAPTURE_MODE = AUTO, SIZE_BASED_CLEANUP_MODE = AUTO, MAX_PLANS_PER_QUERY = 200, WAIT_STATS_CAPTURE_MODE = ON)
GO
USE [ProductStore]
GO
/****** Object: Table [dbo].[Product] Script Date: 27.01.2026 09:58:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Product](
[id] [int] NOT NULL,
[name] [nvarchar](50) NOT NULL,
[category] [nvarchar](50) NOT NULL,
[price] [float] NOT NULL,
[discount] [int] NULL,
[quantity] [int] NULL,
[measurement] [nvarchar](50) NULL,
[producer] [nvarchar](50) NULL,
[country] [nvarchar](50) NULL,
[supplier] [nvarchar](50) NULL,
[date_of_delivery] [date] NULL,
[expire_date] [date] NULL,
CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED
(
[id] 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
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (1, N'Bread', N'Bakery', 50, 0, 5, N'Package', N'Khlebov', N'Ukraine', N'FastDeliveryUK', CAST(N'2026-01-05' AS Date), CAST(N'2026-01-11' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (2, N'Pretzel', N'Bakery', 35, 0, 17, N'Package', N'Khlebov', N'Ukraine', N'FromFactory', CAST(N'2026-01-13' AS Date), CAST(N'2026-04-11' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (3, N'Croissant', N'Bakery', 65, 0, 11, N'Piece', N'Khlebov', N'Ukraine', N'FromFactory', CAST(N'2026-01-13' AS Date), CAST(N'2026-06-25' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (4, N'Chocolate', N'Sweets', 150, 10, 6, N'Bar', N'Roshen', N'Ukraine', N'Milov', CAST(N'2026-01-03' AS Date), CAST(N'2027-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (5, N'Cake', N'Sweets', 650, 0, 8, N'Box', N'Roshen', N'Ukraine', N'Milov', CAST(N'2026-01-03' AS Date), CAST(N'2027-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (6, N'Cookie', N'Sweets', 50, 0, 20, N'Package', N'Roshen', N'Ukraine', N'Milov', CAST(N'2026-01-03' AS Date), CAST(N'2027-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (7, N'Chocolate bar', N'Sweets', 20, 0, 40, N'Bar', N'Roshen', N'Ukraine', N'Milov', CAST(N'2026-01-03' AS Date), CAST(N'2027-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (8, N'Marmalade', N'Sweets', 24.9, 15, 12, N'Package', N'Haribo', N'Germany', N'WorldwideDel', CAST(N'2026-02-10' AS Date), CAST(N'2028-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (9, N'Cheese', N'Dairy', 250, 50, 22, N'Package', N'Ferma', N'Ukraine', N'MilkyDel', CAST(N'2026-01-20' AS Date), CAST(N'2028-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (10, N'Milk', N'Dairy', 60, 0, 40, N'Bottle', N'Molokiia', N'Ukraine', N'MilkyDel', CAST(N'2026-01-21' AS Date), CAST(N'2026-02-21' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (11, N'Sung', N'Dairy', 62, 10, 14, N'Package', N'Molokiia', N'Ukraine', N'MilkyDel', CAST(N'2026-01-21' AS Date), CAST(N'2026-02-21' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (12, N'Chips', N'Snacks', 120, 0, 23, N'Package', N'Pringles', N'USA', N'WorldwideDel', CAST(N'2026-01-15' AS Date), CAST(N'2028-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (13, N'Pepsi', N'Drinks', 45, 0, 35, N'Bottle', N'PepsiCo', N'USA', N'WorldwideDel', CAST(N'2026-01-15' AS Date), CAST(N'2028-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (14, N'Tea', N'Drinks', 139, 10, 34, N'Package', N'Lovare', N'Ukraine', N'FastDeliveryUK', CAST(N'2026-01-05' AS Date), CAST(N'2028-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (15, N'Coffee', N'Drinks', 200, 5, 23, N'Package', N'Jacobs', N'Germany', N'FastDeliveryUK', CAST(N'2026-01-15' AS Date), CAST(N'2029-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (16, N'Latiao', N'Snacks', 100, 0, 100, N'Package', N'GoldenMill', N'China', N'WorldwideDel', CAST(N'2026-02-02' AS Date), CAST(N'2030-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (17, N'Ramen', N'Pasta', 100, 20, 50, N'Package', N'SAMYANG', N'Korea', N'WorldwideDel', CAST(N'2026-02-01' AS Date), CAST(N'2030-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (18, N'Shrimp', N'Seafood', 300, 0, 50, N'Package', N'VodniiSvit', N'Ukraine', N'FastDeliveryUK', CAST(N'2026-01-23' AS Date), CAST(N'2026-03-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (19, N'Caviar', N'Seafood', 700, 0, 40, N'Tin', N'Kamchadal', N'Ukraine', N'FastDeliveryUK', CAST(N'2026-01-13' AS Date), CAST(N'2029-01-01' AS Date))
INSERT [dbo].[Product] ([id], [name], [category], [price], [discount], [quantity], [measurement], [producer], [country], [supplier], [date_of_delivery], [expire_date]) VALUES (20, N'Basturma', N'Meat', 500, 5, 35, N'Package', N'XBX', N'Poland', N'WorldwideDel', CAST(N'2026-01-23' AS Date), CAST(N'2028-01-01' AS Date))
GO
USE [master]
GO
ALTER DATABASE [ProductStore] SET READ_WRITE
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment