Exercises
Exercises to help explain how Data Modeling works!
Modeling Places
In this exercise, you'll model two places for storage in a reviews website like Yelp, Google Local, or Foursquare.
We're not terribly worried about format for this. PAIR UP and don't worry about getting JSON exactly right - the important part is "name" : "value".
If you get stuck trying to read something you wrote, here's a JSON Parser that will organize things for you.
- First, create a new file - call it places.json
- Start with an array with two or more objects -
[{}, {}, {}]
- We're going to model places from this list, or choose your own favorite places!
- Ask yourself these questions:
- What properties do each of these places have? An address? A name?
- How are they different?
- What makes them different in the same way? (like type: grocery store, or pub, or coffee shop)
- What information is useful, vs not useful? (phone numbers are useful, but number of bricks isn't. Unless you are building a national brick database.)
- What is someone looking for when they look up information about this thing? What am I looking for?
- Try to store some information unique to each place - maybe a section from a menu at a food place, or credentials for the dentist. Models don't always have to be the same, but they do need a "baseline" of similarity.
Modeling Movies!
Making movies takes lots of relationships - Actors, Producers, Studios - we don't want to duplicate data, so let's form some relationships!
- First, create a new file - call it movies.json
- Start with three arrays with four or more objects -
Movies = [{}, {}, {}, {}]
Actors = [{}, {}, {}, {}]
Studios = [{}, {}, {}, {}]
- We're going to model four different movies!
- These share actors, so we're going to assign an ID to each actor, studio, and movie.
- In each movie there are lots of actors - list only the top-billed actors for simplicity's sake. Create an array to hold just the IDs of the actors.
- Reference the ID of the actor you want to name by looking in your list of actors, and using the ID field.
- Do the same for the studios- reference them by ID (but you don't have to use an array)
- Try to simplify the studios - don't distinguish between Universal Studios and Universal Studios France. We're not IMDB :)