-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatabase_design.tex.bak
220 lines (173 loc) · 7.28 KB
/
database_design.tex.bak
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
\Chapter{Google Data Store Design}
Google Data Store is based on the Big Table architecture. It is a Hashmap with keys mapped to multi dimentional arrays. These arrays represent columns or collection of columns. The number of columns in Google Data Store is not fixed. For every web application deployed in Google App Store, it generates a unique application id (ApplicationID). Application (ApplicationID) is associated with a Path which defines the hierachy of entity keys. \cite{BigTable}
\section{Entity and Kind}
Every entity must be of particular kind. For example: To create an entity of kind Department, an object of type Entity is created by passing Department as kind:
\hspace{1in} Entity department = new Entity("Department");
An entity can be associated with parent by providing entity type in the constructor.
\hspace{1in} Entity location = new Entity("Department", department.getKey());
Each entity may or may not belong to a group. But Google recommends every entity should belong to a group so that in a distributed environment, group of entities can be stored in a particular cluster. Deleting a parent, does not guarantee deletion of the child. This should be done programmatically by traversing each child. \cite{Entities}
Each entity can have multiple properties. For example:
\hspace{1in} location.setProperty("USA", "");
\hspace{1in} location.setProperty("France", "");
\section{Indexes}
Indexes are auto generated in the Google App Store. Each application contains an index table with rows corresponding to entities and columns corresponding to property values. Index entries are added based on the combination of the property name and property values. So care must be taken to avoid index explosion. For example:
\hspace{1in} Indexes
\hspace{1.2in}kind =Model;
\hspace{1.3in} properrties;
\hspace{1.5in} name = type1
\hspace{1.5in} name = type2
If there are three values of type1 and four values of type2, combination of the these will result 12 index table entries. Google App Store allows 200 entries in the index table for every put operation. To avoid indexing errors, property names can be grouped into multiple entities.
\hspace{1in} Indexes:
\hspace{1.2in}kind =Model1:
\hspace{1.3in} properties:
\hspace{1.5in} name = type1
\hspace{1in} Indexes:
\hspace{1.2in}kind =Model2:
\hspace{1.3in} properties:
\hspace{1.5in} name = type2
Custom indexes can be added by updating indexing.yaml file by specifying which properties need to be indexed.\cite{Indexes}
\section{Data Modeling}
GradeBoard uses Google App Store API for defining models. The attributes of an entity can be updated dynamically since there is no limitation on the number of columns. Table~\ref{table:Entities} defines entities identified in the GradeBoard application.
\begin{table}[H]
\caption{Entity Types}\label{table:Entities}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Entity Kind & Key \\ \hline
Quarter & int \\ \hline
Course & int \\ \hline
Component & int \\ \hline
Grade & int \\ \hline
Instructor & int \\ \hline
Student & int \\ \hline
Auth & int \\ \hline
\end{tabular}
\end{center}
\end{table}
Each entity is defined in the Data Store with ApplicationID (unique across entire store) and a Path. Path defines hieararchy begining with the root entity until the current node is found. The relationship is identified by ancestor path. Path defines the ancestor relationships among entities.Table~\ref{table:EntPath} defines paths identified in the GradeBoard application.
\begin{table}[H]
\caption{Entity Path}\label{table:EntPath}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Value \\ \hline
ApplicationID & {Auto generated value}\\ \hline
Quarter & "" \\ \hline
Course & Course:Quarter \\ \hline
Component & Course:Component \\ \hline
Grade & Course:Component:Grade \\ \hline
Instructor & "" \\ \hline
Student & Course:Student \\ \hline
Auth & Auth:Instructor \\ \hline
\end{tabular}
\end{center}
\end{table}
Table~\ref{table:Quarter} defines Quarter Entity in the GradeBoard application.
\begin{table}[H]
\caption{Quarter Entity}\label{table:Quarter}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
Name & str* \\ \hline
Startdate & date \\ \hline
Enddate & date \\ \hline
\end{tabular}
\end{center}
\end{table}
Course entity contains details about the course. Table~\ref{table:EntCourse} defines Course Entity in the GradeBoard application.
\begin{table}[H]
\caption{Course Entity}\label{table:EntCourse}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
Coursename & str* \\ \hline
Description & str* \\ \hline
Number & int \\ \hline
Units & int \\ \hline
Totalseats & int \\ \hline
Seatstaken & int \\ \hline
Classtime & date \\ \hline
Location & str* \\ \hline
\end{tabular}
\end{center}
\end{table}
Component is a PolyModel Entity. A PolyModel entity can be thought of as an abstract class which can be inherited by multiple entities. The query on a parent results in the data stored in the inherited child entity. This concept is similar to polymorphism om object oriented programming.
Table~\ref{table:EntComponent} defines EntComponent Entity in the GradeBoard application.
\begin{table}[H]
\caption{Component Entity}\label{table:EntComponent}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
Name & str*\\ \hline
Deadline & date \\ \hline
Points & int \\ \hline
\end{tabular}
\end{center}
\end{table}
Grade entity inherits from Component entity. Table~\ref{table:EntGrade} defines Grade entity in the GradeBoard application.
\begin{table}[H]
\caption{Grade Entity}\label{table:EntGrade}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
Score & int\\ \hline
StudentId & ReferenceProperty \\ \hline
\end{tabular}
\end{center}
\end{table}
Table~\ref{table:EntStudent} defines Student entity in the GradeBoard application. Student entity contains a property named SecretId for masking the Id when a grade sheet for other students is constructed. Student who is viewing the grade sheet will see SecretId of the other students not the actual name.
\begin{table}[H]
\caption{Student Entity}\label{table:EntStudent}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
Firstname & str*\\ \hline
Lastname & str* \\ \hline
Email & str* \\ \hline
SecretId & int \\ \hline
\end{tabular}
\end{center}
\end{table}
Table~\ref{table:EntInstructor} defines Instructor entity in the GradeBoard application. Instructor information is populated from Google account that instructor uses to log in. Administrator authorizes and adds the instructor account for GradeBoard application.
\begin{table}[H]
\caption{Instructor Entity}\label{table:EntInstructor}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
GoogleUser & User\\ \hline
\end{tabular}
\end{center}
\end{table}
Table~\ref{table:EntAdmin} defines Admin entity in the GradeBoard application. Admin entity is pre-populated or manually updated by the administrator.
\begin{table}[H]
\caption{Admin Entity}\label{table:EntAdmin}
\textbf{ }
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Key & Type \\ \hline
Id & int\\ \hline
GoogleUser & User\\ \hline
\end{tabular}
\end{center}
\end{table}