-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinal_BookRegistration.sql
More file actions
50 lines (41 loc) · 1.09 KB
/
Final_BookRegistration.sql
File metadata and controls
50 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use master
IF DB_ID('BookRegistration') IS NOT NULL
DROP DATABASE BookRegistration
GO
CREATE DATABASE BookRegistration
GO
USE BookRegistration
GO
CREATE TABLE Customer
(
CustomerID int PRIMARY KEY IDENTITY
,DateOfBirth date NOT NULL
,FirstName varchar(30) NOT NULL
,LastName varchar(35) NOT NULL
,Title varchar(30) NOT NULL
)
GO
INSERT INTO Customer(DateOfBirth, FirstName,LastName,Title)
VALUES('Jan 01, 1980', 'Charles', 'Babbage', 'Mr.')
,('April 12, 1987', 'E.F.', 'Codd', 'Dr.')
,('May 1, 1950', 'Ada', 'Lovelace', 'Ms.')
CREATE TABLE Book
(
ISBN char(13) PRIMARY KEY
,Price smallmoney NOT NULL
,Title varchar(100) NOT NULL
)
GO
INSERT INTO Book (ISBN, Price, Title)
VALUES ('1234567890ABC', 9.99, 'Intro to databases')
,('IEHBMEIUS1234', 12.35, 'Learning Programming')
CREATE TABLE Registration
(
CustomerID int REFERENCES Customer(CustomerID)
,ISBN char(13) REFERENCES Book(ISBN)
,RegDate smalldatetime NOT NULL
,PRIMARY KEY(CustomerID, ISBN)
)
INSERT INTO Registration (CustomerID, ISBN, RegDate)
VALUES(3, 'IEHBMEIUS1234', GETDATE())
,(2, '1234567890ABC', GETDATE() - 7)