-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecipeShopper.Scripts.sql
More file actions
58 lines (54 loc) · 1.43 KB
/
Copy pathRecipeShopper.Scripts.sql
File metadata and controls
58 lines (54 loc) · 1.43 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
51
52
53
54
55
56
57
58
create database RecipeShopper
go
use RecipeShopper
go
if object_id('ShoplistIngredient', 'u') is not null
drop table ShoplistIngredient
go
if object_id('RecipeIngredient', 'u') is not null
drop table RecipeIngredient
go
if object_id('Shoplist', 'u') is not null
drop table Shoplist
go
if object_id('Recipe', 'u') is not null
drop table Recipe
go
if object_id('Ingredient', 'u') is not null
drop table Ingredient
go
if object_id('AmountType', 'u') is not null
drop table AmountType
go
create table Ingredient (
id int identity(1,1) primary key,
description varchar(100)
)
create table AmountType (
id int identity(1,1) primary key,
description varchar(100)
)
create table Shoplist (
id int identity(1,1) primary key,
creationDate datetime not null
)
create table ShoplistIngredient (
id int identity(1,1) primary key,
shoplistId int foreign key references Shoplist(id),
ingredientId int foreign key references Ingredient(id),
amountTypeId int foreign key references AmountType(id),
amount decimal
)
create table Recipe (
id int identity(1,1) primary key,
name varchar(100),
steps varchar(MAX)
)
create table RecipeIngredient (
id int identity(1,1) primary key,
recipeId int foreign key references Recipe(id) on delete cascade,
ingredientId int foreign key references Ingredient(id),
amountTypeId int foreign key references AmountType(id),
amount decimal
)
go