SlideShare a Scribd company logo
Cüneyt Hocam Merhabalar…
Sunum bitiminde sorduğumda sanırsam veritabanı kodlarını da istemiştiniz,
emin değilim. Ayrıca, onları rapora ilave etmek istemedik; çünkü
raporu gereksiz şişireceğini düşündük ve o yüzden burada paylaştık.
Umarım beğenirsiniz.
SE [library]
GO
/****** Object: Table [dbo].[sex] Script Date: 05/19/2014 20:04:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[sex](
[Id] [int] IDENTITY(1,1) NOT NULL,
[sex] [nvarchar](50) NULL,
CONSTRAINT [PK_sex] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[city] Script Date: 05/19/2014 20:04:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[city](
[cityID] [int] IDENTITY(1,1) NOT NULL,
[CityName] [nchar](10) NULL,
CONSTRAINT [PK_city] PRIMARY KEY CLUSTERED
(
[cityID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Category] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Category](
[CategoryId] [int] IDENTITY(1,1) NOT NULL,
[CategoryName] [nvarchar](50) NULL,
CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED
(
[CategoryId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Author] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Author](
[AuthorId] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Author] PRIMARY KEY CLUSTERED
(
[AuthorId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Status] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Status](
[statuID] [int] IDENTITY(1,1) NOT NULL,
[Status] [nvarchar](50) NULL,
CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED
(
[statuID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Book] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Book](
[BookId] [int] IDENTITY(1,1) NOT NULL,
[Title] [nvarchar](250) NULL,
[ISBN] [nvarchar](50) NULL,
[PublishDate] [date] NULL,
[StatusId] [int] NULL,
[CategoryId] [int] NULL,
[Place] [nvarchar](250) NULL,
[PlaceInLibrary] [nvarchar](50) NULL,
[Date] [date] NULL,
[Photo] [nvarchar](50) NULL,
CONSTRAINT [PK_Book] PRIMARY KEY CLUSTERED
(
[BookId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Address] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Address](
[AddressId] [int] IDENTITY(1,1) NOT NULL,
[Adress] [nvarchar](250) NULL,
[CityId] [int] NULL,
CONSTRAINT [PK_Address] PRIMARY KEY CLUSTERED
(
[AddressId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[book_Author] Script Date: 05/19/2014
20:04:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[book_Author](
[id] [int] IDENTITY(1,1) NOT NULL,
[bookId] [int] NULL,
[authorId] [int] NULL,
CONSTRAINT [PK_book_Author] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[sp_City] Script Date: 05/19/2014
20:04:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[sp_City]
as begin
select l.adress,s.cityName from Address l
inner join city s on l.cityId=s.cityID
end
GO
/****** Object: Table [dbo].[Users] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
[UserId] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NULL,
[SexId] [int] NULL,
[Phone] [nvarchar](50) NULL,
[Email] [nvarchar](50) NULL,
[Tc] [nvarchar](50) NULL,
[AddressId] [int] NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED
(
[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[sp_User] Script Date: 05/19/2014
20:04:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[sp_User]
as begin
select u.Name,u.LastName,u.Email,u.Phone,a.Adress,c.CityName,s.sex
from Users u
inner join sex s on s.Id=u.SexId
inner join Address a on a.AddressId=u.AddressId
inner join city c on c.cityID=a.CityId
end
GO
/****** Object: StoredProcedure [dbo].[sp_Sex] Script Date: 05/19/2014
20:04:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[sp_Sex]
as begin
select l.name,l.LastName,s.Sex,l.Email from users l
inner join sex s on l.sexId=s.Id
end
GO
/****** Object: Table [dbo].[TBorrow] Script Date: 05/19/2014 20:04:52
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBorrow](
[BorrowId] [int] IDENTITY(1,1) NOT NULL,
[UserId] [int] NULL,
[BookId] [int] NULL,
[BorrowDate] [nvarchar](50) NULL,
[ReturnDate] [nvarchar](50) NULL,
CONSTRAINT [PK_brrow] PRIMARY KEY CLUSTERED
(
[BorrowId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: View [dbo].[vw_sp_book_Author] Script Date: 05/19/2014
20:04:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view [dbo].[vw_sp_book_Author]
as
select
b.BookId,b.Title,a.Name,a.LastName,b.ISBN,b.PublishDate,s.Status,c.Catego
ryName,b.Place,b.PlaceInLibrary,b.Date,b.Photo from book_author ba
inner join Book b on b.BookId=ba.bookId
inner join Author a on a.AuthorId=ba.authorId
inner join Status s on s.statuID=b.StatusId
inner join Category c on c.CategoryId=b.CategoryId
GO
/****** Object: StoredProcedure [dbo].[sp_book_Author] Script Date:
05/19/2014 20:04:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[sp_book_Author]
as begin
select
b.BookId,b.Title,a.Name,a.LastName,b.ISBN,b.PublishDate,s.Status,c.Catego
ryName,b.Place,b.PlaceInLibrary,b.Date,b.Photo from book_author ba
inner join Book b on b.BookId=ba.bookId
inner join Author a on a.AuthorId=ba.authorId
inner join Status s on s.statuID=b.StatusId
inner join Category c on c.CategoryId=b.CategoryId
end
GO
/****** Object: StoredProcedure [dbo].[sp_Borrow] Script Date:
05/19/2014 20:04:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[sp_Borrow]
as begin
select b.borrowId,b.UserId,bk.Title,s.Status,b.borrowdate,b.returndate from
TBorrow b
inner join Book bk on bk.BookId=b.BookId
inner join Status s on s.statuID=bk.StatusId
end
GO
/****** Object: ForeignKey [FK_Address_Address] Script Date:
05/19/2014 20:04:52 ******/
ALTER TABLE [dbo].[Address] WITH CHECK ADD CONSTRAINT
[FK_Address_Address] FOREIGN KEY([AddressId])
REFERENCES [dbo].[Address] ([AddressId])
GO
ALTER TABLE [dbo].[Address] CHECK CONSTRAINT [FK_Address_Address]
GO
/****** Object: ForeignKey [FK_Address_city] Script Date: 05/19/2014
20:04:52 ******/
ALTER TABLE [dbo].[Address] WITH CHECK ADD CONSTRAINT
[FK_Address_city] FOREIGN KEY([CityId])
REFERENCES [dbo].[city] ([cityID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Address] CHECK CONSTRAINT [FK_Address_city]
GO
/****** Object: ForeignKey [FK_Book_Category] Script Date: 05/19/2014
20:04:52 ******/
ALTER TABLE [dbo].[Book] WITH CHECK ADD CONSTRAINT
[FK_Book_Category] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Category] ([CategoryId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Book] CHECK CONSTRAINT [FK_Book_Category]
GO
/****** Object: ForeignKey [FK_Book_Status] Script Date: 05/19/2014
20:04:52 ******/
ALTER TABLE [dbo].[Book] WITH CHECK ADD CONSTRAINT
[FK_Book_Status] FOREIGN KEY([StatusId])
REFERENCES [dbo].[Status] ([statuID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Book] CHECK CONSTRAINT [FK_Book_Status]
GO
/****** Object: ForeignKey [FK_book_Author_Author] Script Date:
05/19/2014 20:04:52 ******/
ALTER TABLE [dbo].[book_Author] WITH CHECK ADD CONSTRAINT
[FK_book_Author_Author] FOREIGN KEY([authorId])
REFERENCES [dbo].[Author] ([AuthorId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[book_Author] CHECK CONSTRAINT
[FK_book_Author_Author]
GO
/****** Object: ForeignKey [FK_book_Author_Book] Script Date:
05/19/2014 20:04:52 ******/
ALTER TABLE [dbo].[book_Author] WITH CHECK ADD CONSTRAINT
[FK_book_Author_Book] FOREIGN KEY([bookId])
REFERENCES [dbo].[Book] ([BookId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[book_Author] CHECK CONSTRAINT
[FK_book_Author_Book]
GO
/****** Object: ForeignKey [FK_brrow_Book] Script Date: 05/19/2014
20:04:52 ******/
ALTER TABLE [dbo].[TBorrow] WITH NOCHECK ADD CONSTRAINT
[FK_brrow_Book] FOREIGN KEY([BookId])
REFERENCES [dbo].[Book] ([BookId])
GO
ALTER TABLE [dbo].[TBorrow] CHECK CONSTRAINT [FK_brrow_Book]
GO
/****** Object: ForeignKey [FK_brrow_Users] Script Date: 05/19/2014
20:04:52 ******/
ALTER TABLE [dbo].[TBorrow] WITH CHECK ADD CONSTRAINT
[FK_brrow_Users] FOREIGN KEY([UserId])
REFERENCES [dbo].[Users] ([UserId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[TBorrow] CHECK CONSTRAINT [FK_brrow_Users]
GO
/****** Object: ForeignKey [FK_Users_Address] Script Date: 05/19/2014
20:04:52 ******/
ALTER TABLE [dbo].[Users] WITH CHECK ADD CONSTRAINT
[FK_Users_Address] FOREIGN KEY([AddressId])
REFERENCES [dbo].[Address] ([AddressId])
GO
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_Users_Address]
GO
THAT’S THE END OF THE DOCUMENT. GO AND GET SOME
BEVERAGE… :)

More Related Content

PPTX
JavaScript Objects and OOP Programming with JavaScript
PDF
Unidad 4 actividad 1
PPT
PHP webboard
PDF
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
PDF
NDC London 2013 - Mongo db for c# developers
PDF
MongoD Essentials
PPT
PHP cart
PDF
How te bring common UI patterns to ADF
JavaScript Objects and OOP Programming with JavaScript
Unidad 4 actividad 1
PHP webboard
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
NDC London 2013 - Mongo db for c# developers
MongoD Essentials
PHP cart
How te bring common UI patterns to ADF

What's hot (20)

PDF
Transparent Object Persistence with FLOW3
PPTX
How to Bring Common UI Patterns to ADF
PDF
[ HackFest.pl 2012] Testing - what for and how
PDF
[ WrocLoveRb 2012] user perspective testing using ruby
PDF
Clean code
PDF
The Age of Slacktivism Motivating the Masses
KEY
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
PPTX
PDF
How else can you write the code in PHP?
PDF
Drush. Secrets come out.
KEY
Introduction à CoffeeScript pour ParisRB
PDF
San Francisco Java User Group
DOC
Webtechnology lab
PDF
Cleaner, Leaner, Meaner: Refactoring your jQuery
KEY
MongoDB
PDF
Capstone Website Code
PDF
php plus mysql
PDF
Xarxes socials
PPTX
Building Your First Widget
PDF
JSON and Swift, Still A Better Love Story Than Twilight
Transparent Object Persistence with FLOW3
How to Bring Common UI Patterns to ADF
[ HackFest.pl 2012] Testing - what for and how
[ WrocLoveRb 2012] user perspective testing using ruby
Clean code
The Age of Slacktivism Motivating the Masses
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
How else can you write the code in PHP?
Drush. Secrets come out.
Introduction à CoffeeScript pour ParisRB
San Francisco Java User Group
Webtechnology lab
Cleaner, Leaner, Meaner: Refactoring your jQuery
MongoDB
Capstone Website Code
php plus mysql
Xarxes socials
Building Your First Widget
JSON and Swift, Still A Better Love Story Than Twilight
Ad

Similar to Database scripts (20)

TXT
DOCX
Codigo Server Festival
PPTX
DNN Database Tips & Tricks
PDF
Procedures
DOC
Implementation Specifications
PPTX
SQL Server 2008 Portfolio
DOCX
Sql
PPT
Greg Lewis SQL Portfolio
PDF
Permissions script for SQL Permissions
PDF
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
PPT
FMDB - SLC-Cocoaheads
PDF
Introducción rápida a SQL
PDF
Simple Strategies for faster knowledge discovery in big data
PDF
Functions
PDF
Sql vs no sql diponkar paul-april 2020-Toronto PASS
DOCX
supporting t-sql scripts for Heap vs clustered table
PDF
Date dimension table - part II
PPTX
SQL-MySQL-Commands-Basic.pptx
PDF
Pdxpugday2010 pg90
PPTX
Azure sql insert perf
Codigo Server Festival
DNN Database Tips & Tricks
Procedures
Implementation Specifications
SQL Server 2008 Portfolio
Sql
Greg Lewis SQL Portfolio
Permissions script for SQL Permissions
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
FMDB - SLC-Cocoaheads
Introducción rápida a SQL
Simple Strategies for faster knowledge discovery in big data
Functions
Sql vs no sql diponkar paul-april 2020-Toronto PASS
supporting t-sql scripts for Heap vs clustered table
Date dimension table - part II
SQL-MySQL-Commands-Basic.pptx
Pdxpugday2010 pg90
Azure sql insert perf
Ad

Recently uploaded (20)

PDF
.pdf is not working space design for the following data for the following dat...
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
Qualitative Qantitative and Mixed Methods.pptx
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
SAP 2 completion done . PRESENTATION.pptx
PPTX
Introduction to machine learning and Linear Models
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PDF
annual-report-2024-2025 original latest.
PDF
Clinical guidelines as a resource for EBP(1).pdf
PDF
Introduction to the R Programming Language
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
IB Computer Science - Internal Assessment.pptx
.pdf is not working space design for the following data for the following dat...
Fluorescence-microscope_Botany_detailed content
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Supervised vs unsupervised machine learning algorithms
Qualitative Qantitative and Mixed Methods.pptx
STERILIZATION AND DISINFECTION-1.ppthhhbx
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
SAP 2 completion done . PRESENTATION.pptx
Introduction to machine learning and Linear Models
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
annual-report-2024-2025 original latest.
Clinical guidelines as a resource for EBP(1).pdf
Introduction to the R Programming Language
Galatica Smart Energy Infrastructure Startup Pitch Deck
Reliability_Chapter_ presentation 1221.5784
IB Computer Science - Internal Assessment.pptx

Database scripts

  • 1. Cüneyt Hocam Merhabalar… Sunum bitiminde sorduğumda sanırsam veritabanı kodlarını da istemiştiniz, emin değilim. Ayrıca, onları rapora ilave etmek istemedik; çünkü raporu gereksiz şişireceğini düşündük ve o yüzden burada paylaştık. Umarım beğenirsiniz. SE [library] GO /****** Object: Table [dbo].[sex] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[sex]( [Id] [int] IDENTITY(1,1) NOT NULL, [sex] [nvarchar](50) NULL, CONSTRAINT [PK_sex] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[city] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[city]( [cityID] [int] IDENTITY(1,1) NOT NULL, [CityName] [nchar](10) NULL, CONSTRAINT [PK_city] PRIMARY KEY CLUSTERED ( [cityID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
  • 2. GO /****** Object: Table [dbo].[Category] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Category]( [CategoryId] [int] IDENTITY(1,1) NOT NULL, [CategoryName] [nvarchar](50) NULL, CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED ( [CategoryId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Author] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Author]( [AuthorId] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NOT NULL, [LastName] [nvarchar](50) NOT NULL, CONSTRAINT [PK_Author] PRIMARY KEY CLUSTERED ( [AuthorId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Status] Script Date: 05/19/2014 20:04:52 ******/
  • 3. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Status]( [statuID] [int] IDENTITY(1,1) NOT NULL, [Status] [nvarchar](50) NULL, CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED ( [statuID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Book] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Book]( [BookId] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](250) NULL, [ISBN] [nvarchar](50) NULL, [PublishDate] [date] NULL, [StatusId] [int] NULL, [CategoryId] [int] NULL, [Place] [nvarchar](250) NULL, [PlaceInLibrary] [nvarchar](50) NULL, [Date] [date] NULL, [Photo] [nvarchar](50) NULL, CONSTRAINT [PK_Book] PRIMARY KEY CLUSTERED ( [BookId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Address] Script Date: 05/19/2014 20:04:52
  • 4. ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Address]( [AddressId] [int] IDENTITY(1,1) NOT NULL, [Adress] [nvarchar](250) NULL, [CityId] [int] NULL, CONSTRAINT [PK_Address] PRIMARY KEY CLUSTERED ( [AddressId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[book_Author] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[book_Author]( [id] [int] IDENTITY(1,1) NOT NULL, [bookId] [int] NULL, [authorId] [int] NULL, CONSTRAINT [PK_book_Author] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: StoredProcedure [dbo].[sp_City] Script Date: 05/19/2014 20:04:50 ******/ SET ANSI_NULLS ON GO
  • 5. SET QUOTED_IDENTIFIER ON GO create proc [dbo].[sp_City] as begin select l.adress,s.cityName from Address l inner join city s on l.cityId=s.cityID end GO /****** Object: Table [dbo].[Users] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Users]( [UserId] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NULL, [LastName] [nvarchar](50) NULL, [SexId] [int] NULL, [Phone] [nvarchar](50) NULL, [Email] [nvarchar](50) NULL, [Tc] [nvarchar](50) NULL, [AddressId] [int] NULL, CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ( [UserId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: StoredProcedure [dbo].[sp_User] Script Date: 05/19/2014 20:04:50 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[sp_User] as begin
  • 6. select u.Name,u.LastName,u.Email,u.Phone,a.Adress,c.CityName,s.sex from Users u inner join sex s on s.Id=u.SexId inner join Address a on a.AddressId=u.AddressId inner join city c on c.cityID=a.CityId end GO /****** Object: StoredProcedure [dbo].[sp_Sex] Script Date: 05/19/2014 20:04:50 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[sp_Sex] as begin select l.name,l.LastName,s.Sex,l.Email from users l inner join sex s on l.sexId=s.Id end GO /****** Object: Table [dbo].[TBorrow] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[TBorrow]( [BorrowId] [int] IDENTITY(1,1) NOT NULL, [UserId] [int] NULL, [BookId] [int] NULL, [BorrowDate] [nvarchar](50) NULL, [ReturnDate] [nvarchar](50) NULL, CONSTRAINT [PK_brrow] PRIMARY KEY CLUSTERED ( [BorrowId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
  • 7. GO /****** Object: View [dbo].[vw_sp_book_Author] Script Date: 05/19/2014 20:04:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create view [dbo].[vw_sp_book_Author] as select b.BookId,b.Title,a.Name,a.LastName,b.ISBN,b.PublishDate,s.Status,c.Catego ryName,b.Place,b.PlaceInLibrary,b.Date,b.Photo from book_author ba inner join Book b on b.BookId=ba.bookId inner join Author a on a.AuthorId=ba.authorId inner join Status s on s.statuID=b.StatusId inner join Category c on c.CategoryId=b.CategoryId GO /****** Object: StoredProcedure [dbo].[sp_book_Author] Script Date: 05/19/2014 20:04:50 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[sp_book_Author] as begin select b.BookId,b.Title,a.Name,a.LastName,b.ISBN,b.PublishDate,s.Status,c.Catego ryName,b.Place,b.PlaceInLibrary,b.Date,b.Photo from book_author ba inner join Book b on b.BookId=ba.bookId inner join Author a on a.AuthorId=ba.authorId inner join Status s on s.statuID=b.StatusId inner join Category c on c.CategoryId=b.CategoryId end GO /****** Object: StoredProcedure [dbo].[sp_Borrow] Script Date:
  • 8. 05/19/2014 20:04:50 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[sp_Borrow] as begin select b.borrowId,b.UserId,bk.Title,s.Status,b.borrowdate,b.returndate from TBorrow b inner join Book bk on bk.BookId=b.BookId inner join Status s on s.statuID=bk.StatusId end GO /****** Object: ForeignKey [FK_Address_Address] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[Address] WITH CHECK ADD CONSTRAINT [FK_Address_Address] FOREIGN KEY([AddressId]) REFERENCES [dbo].[Address] ([AddressId]) GO ALTER TABLE [dbo].[Address] CHECK CONSTRAINT [FK_Address_Address] GO /****** Object: ForeignKey [FK_Address_city] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[Address] WITH CHECK ADD CONSTRAINT [FK_Address_city] FOREIGN KEY([CityId]) REFERENCES [dbo].[city] ([cityID]) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[Address] CHECK CONSTRAINT [FK_Address_city] GO /****** Object: ForeignKey [FK_Book_Category] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[Book] WITH CHECK ADD CONSTRAINT [FK_Book_Category] FOREIGN KEY([CategoryId])
  • 9. REFERENCES [dbo].[Category] ([CategoryId]) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[Book] CHECK CONSTRAINT [FK_Book_Category] GO /****** Object: ForeignKey [FK_Book_Status] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[Book] WITH CHECK ADD CONSTRAINT [FK_Book_Status] FOREIGN KEY([StatusId]) REFERENCES [dbo].[Status] ([statuID]) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[Book] CHECK CONSTRAINT [FK_Book_Status] GO /****** Object: ForeignKey [FK_book_Author_Author] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[book_Author] WITH CHECK ADD CONSTRAINT [FK_book_Author_Author] FOREIGN KEY([authorId]) REFERENCES [dbo].[Author] ([AuthorId]) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[book_Author] CHECK CONSTRAINT [FK_book_Author_Author] GO /****** Object: ForeignKey [FK_book_Author_Book] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[book_Author] WITH CHECK ADD CONSTRAINT [FK_book_Author_Book] FOREIGN KEY([bookId]) REFERENCES [dbo].[Book] ([BookId]) ON UPDATE CASCADE ON DELETE CASCADE GO
  • 10. ALTER TABLE [dbo].[book_Author] CHECK CONSTRAINT [FK_book_Author_Book] GO /****** Object: ForeignKey [FK_brrow_Book] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[TBorrow] WITH NOCHECK ADD CONSTRAINT [FK_brrow_Book] FOREIGN KEY([BookId]) REFERENCES [dbo].[Book] ([BookId]) GO ALTER TABLE [dbo].[TBorrow] CHECK CONSTRAINT [FK_brrow_Book] GO /****** Object: ForeignKey [FK_brrow_Users] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[TBorrow] WITH CHECK ADD CONSTRAINT [FK_brrow_Users] FOREIGN KEY([UserId]) REFERENCES [dbo].[Users] ([UserId]) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[TBorrow] CHECK CONSTRAINT [FK_brrow_Users] GO /****** Object: ForeignKey [FK_Users_Address] Script Date: 05/19/2014 20:04:52 ******/ ALTER TABLE [dbo].[Users] WITH CHECK ADD CONSTRAINT [FK_Users_Address] FOREIGN KEY([AddressId]) REFERENCES [dbo].[Address] ([AddressId]) GO ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_Users_Address] GO THAT’S THE END OF THE DOCUMENT. GO AND GET SOME BEVERAGE… :)