-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.txt
More file actions
104 lines (92 loc) · 3.1 KB
/
input.txt
File metadata and controls
104 lines (92 loc) · 3.1 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
RELATION publisher :=
u32: publisher_id,
str: name,
str: address,
str: website,
pk: publisher_id
;
RELATION publisher + {
(1, 'Charles Scribner\'s Sons', 'New York, USA', 'https://www.scribners.com'),
(2, 'Secker & Warburg', 'London, UK', 'https://www.seckerwarburg.com'),
(3, 'Harper & Row', 'New York, USA', 'https://www.harperrow.com'),
(4, 'Wayfarer Publishing', 'Melbourne, Australia', 'https://www.wayfarerpublishing.com'),
(5, 'Hearts & Minds Press', 'Toronto, Canada', 'https://www.heartsandmindspress.com')
};
RELATION book :=
u32: book_id,
str: title,
str: isbn,
u16: publication_year,
str: genre,
str: language,
u32: pages,
u32: publisher_id,
pk: book_id,
fk: publisher_id -> publisher
;
RELATION book + {
(1, 'The Great Gatsby', '9780743273565', 1925, 'Novel', 'English', 180, 1),
(2, '1984', '9780451524935', 1949, 'Dystopian', 'English', 328, 2),
(3, 'One Hundred Years of Solitude', '9780060883287', 1967, 'Magical Realism', 'Spanish', 417, 3),
(4, 'Pride and Prejudice', '9780141439518', 1813, 'Romance', 'English', 279, 1),
(5, 'Animal Farm', '9780451526342', 1945, 'Political Satire', 'English', 112, 2),
(6, 'Timeless Tales', '9781234567890', 2000, 'Anthology', 'English', 350, 1),
(7, 'The Wanderer\'s Guide', '9789876543210', 2015, 'Fantasy', 'English', 400, 4),
(8, 'Romance Revisited', '9781928374650', 2020, 'Romance', 'English', 310, 5)
};
RELATION author :=
u32: author_id,
str: name,
str: country,
dt: dob,
pk: author_id
;
RELATION author + {
(1, 'F. Scott Fitzgerald', 'USA', '1896-09-24'),
(2, 'George Orwell', 'UK', '1903-06-25'),
(3, 'Gabriel García Márquez', 'Colombia', '1927-03-06'),
(4, 'Jane Austen', 'UK', '1775-12-16'),
(5, 'A. N. Other', 'Canada', '1980-01-01'),
(6, 'Emily Winters', 'Australia', '1975-07-15')
};
// many to many relationship table
RELATION mydb.mygroup.book_authors :=
u32: book_id,
u32: author_id,
pk: (book_id, author_id),
fk: book_id -> book,
fk: author_id -> author
;
RELATION book_authors + {
(1, 1), // "The Great Gatsby" by F. Scott Fitzgerald
(2, 2), // "1984" by George Orwell
(3, 3), // "One Hundred Years of Solitude" by Gabriel García Márquez
(4, 4), // "Pride and Prejudice" by Jane Austen
(5, 2), // "Animal Farm" by George Orwell
(6, 1), // "Timeless Tales" by F. Scott Fitzgerald
(6, 3), // "Timeless Tales" co-authored by Gabriel García Márquez
(7, 5), // "The Wanderer's Guide" by A. N. Other
(8, 4), // "Romance Revisited" by Jane Austen
(8, 6) // "Romance Revisited" co-authored by Emily Winters
};
NewBooks :=
F: book
P: *
S: publication_year >= 2020
;
UK_Authors :=
F: author
P: author_id
S: country = 'UK'
;
US_Authors_Old :=
F: author
P: author_id
S: country = 'USA'
&& publication_year < 2020
;
AuthorBooks := book_authors >< author >< book;
New_UK_US_AuthorBooks := AuthorBooks << (UK_Authors + US_Authors);
NewAuthorBooks := AuthorBooks << NewBooks;
OldAuthorBooks := AuthorBooks !> NewBooks;
RETURN NewAuthorBooks;