Проектирование и реализация структуры базы данных в СУБД MS SQL server 2008 R2

Автор работы: Пользователь скрыл имя, 08 Декабря 2014 в 12:00, лабораторная работа

Описание работы

Так как предусматривается возможность авторизации / регистрации, то, разумеется, необходимо организовать таблицы: регистрация, в которой будут храниться логин и пароль пользователя и таблица «информация о пользователе», в которой будут храниться все личные данные. Также при регистрации мы учли возможность создание профиля для поставщика.

Файлы: 1 файл

Лаба 1 БД.docx

— 1.05 Мб (Скачать файл)

GO

 

USE [Internet-market]

GO

 

/****** Object:  Table [dbo].[tablets]    Script Date: 09/29/2014 17:03:43 ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

CREATE TABLE [dbo].[tablets](

[tablet_id] [int] NOT NULL,

[Product_name] [nvarchar](100) NOT NULL,

[OS] [nvarchar](50) NOT NULL,

[Battery] [nvarchar](50) NOT NULL,

[RAM] [nvarchar](50) NOT NULL,

[Processor] [nvarchar](50) NOT NULL,

[Memory] [nvarchar](50) NOT NULL,

[Price] [nvarchar](50) NOT NULL,

[Discount] [nvarchar](50) NULL,

[Bargain price] [nvarchar](50) NULL

) ON [PRIMARY]

 

GO

 

ALTER TABLE [dbo].[tablets]  WITH CHECK ADD  CONSTRAINT [FK_tablets_users info] FOREIGN KEY([tablet_id])

REFERENCES [dbo].[users info] ([Person_id])

GO

 

ALTER TABLE [dbo].[tablets] CHECK CONSTRAINT [FK_tablets_users info]

GO

 

Telephones

USE [Internet-market]

GO

 

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_telephones_users info]') AND parent_object_id = OBJECT_ID(N'[dbo].[telephones]'))

ALTER TABLE [dbo].[telephones] DROP CONSTRAINT [FK_telephones_users info]

GO

 

USE [Internet-market]

GO

 

/****** Object:  Table [dbo].[telephones]    Script Date: 09/29/2014 17:04:20 ******/

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[telephones]') AND type in (N'U'))

DROP TABLE [dbo].[telephones]

GO

 

USE [Internet-market]

GO

 

/****** Object:  Table [dbo].[telephones]    Script Date: 09/29/2014 17:04:20 ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

CREATE TABLE [dbo].[telephones](

[Telephone_id] [int] NOT NULL,

[Product_name] [nvarchar](100) NOT NULL,

[OS] [nvarchar](50) NOT NULL,

[Screen Resolution] [nvarchar](50) NOT NULL,

[Camera] [nvarchar](50) NOT NULL,

[Battery] [nvarchar](50) NOT NULL,

[Price] [nvarchar](50) NOT NULL,

[Discount] [nvarchar](50) NULL,

[Bargain price] [nvarchar](50) NULL

) ON [PRIMARY]

 

GO

 

ALTER TABLE [dbo].[telephones]  WITH CHECK ADD  CONSTRAINT [FK_telephones_users info] FOREIGN KEY([Telephone_id])

REFERENCES [dbo].[users info] ([Person_id])

GO

 

ALTER TABLE [dbo].[telephones] CHECK CONSTRAINT [FK_telephones_users info]

GO

 

 

TV

USE [Internet-market]

GO

 

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tv_users info]') AND parent_object_id = OBJECT_ID(N'[dbo].[tv]'))

ALTER TABLE [dbo].[tv] DROP CONSTRAINT [FK_tv_users info]

GO

 

USE [Internet-market]

GO

 

/****** Object:  Table [dbo].[tv]    Script Date: 09/29/2014 17:04:43 ******/

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tv]') AND type in (N'U'))

DROP TABLE [dbo].[tv]

GO

 

USE [Internet-market]

GO

 

/****** Object:  Table [dbo].[tv]    Script Date: 09/29/2014 17:04:43 ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

CREATE TABLE [dbo].[tv](

[tv_id] [int] NOT NULL,

[Product_name] [nvarchar](100) NOT NULL,

[Screen Resolution] [nvarchar](50) NOT NULL,

[Diagonal] [nvarchar](50) NOT NULL,

[Price] [nvarchar](50) NOT NULL,

[Discount] [nvarchar](50) NULL,

[Bargain price] [nvarchar](50) NULL

) ON [PRIMARY]

 

GO

 

ALTER TABLE [dbo].[tv]  WITH CHECK ADD  CONSTRAINT [FK_tv_users info] FOREIGN KEY([tv_id])

REFERENCES [dbo].[users info] ([Person_id])

GO

 

ALTER TABLE [dbo].[tv] CHECK CONSTRAINT [FK_tv_users info]

GO

 

 

 

 

 


Информация о работе Проектирование и реализация структуры базы данных в СУБД MS SQL server 2008 R2