Database Reference
In-Depth Information
Here's our solution:
// Entity table that will store many videos for a unique user
CREATE TABLE videos (
videoid uuid,
videoname varchar,
username varchar,
description varchar,
// need-to-have
// location map<varchar,varchar>,
// instead using List
location List <varchar>, // compound key
tags List<varchar>,
upload_date timestamp,
PRIMARY KEY (videoid)
);
The points to note here are:
• UUID is a first-class citizen. We told you not to sequence, but that's only
when it is autogenerated. UUIDs on the other hand are OK. In fact, the
video name is not a natural ID.
• A username belongs to one user, but note that we duplicated the username
that we needed right here right now.
• A set is not a list, but it's exactly what we need here. Unfortunately, Phoenix
does not provide for a set object, so we use a list. However, keep in mind the
real data structure that we need.
• Note that we made the location a <String, String> map, where the key
is the location and the value is the URI of the video. That's because content
delivery systems usually store videos in different locations. In this way,
we are again imitating lists.
 
Search WWH ::




Custom Search