7/3/2023 0 Comments Reddit project haven![]() ![]() If you can’t quite figure out how it might look, keep the scenario in mind as you go through the next few lessons. The trick is identifying what should be a different model and how these models will relate to each other via simple associations (all the ones below are has_many, has_one and/or belongs_to relationship). Some of these are more difficult than others and you’ll have to use a bit of creativity to infer which columns might need to be present for the scenario to make sense in the real world. Data Model Taskįor each of the following scenarios, write down the models, columns, validations and associations you might use to implement it. Note: We’ll include the :id, :created_at and :updated_at columns but you can safely assume they’re always there since Rails or the database gives them to you automaticallyĪuthors username:string Don’t worry if you’re not quite sure how to implement a given thing, the point here is to start thinking about how the data would be structured.Įxample: You are building a blog for your startup which will have multiple authors and each author can write multiple posts. minimum password length or username uniqueness). That means which models (data tables) will be necessary to store the data (and which columns you will need), which fields of those tables will be subject to validation (e.g. One way to do it is with a list of models and another is to create a visual diagram where each model is represented by a box and you connect them with appropriate arrows.įor each scenario, you’ll be asked to write down the data, associations, and validations necessary to build it. There are a few specific accepted techniques for how to map out models and associations but just do whatever comes naturally to you. You can do it with a pen and paper or, if you’re lucky enough to be around one, a whiteboard. In this warmup, you’ll be given a variety of scenarios and you’ll be asked to map out what the data models will look like for each one. ![]() You may not really know everything when you first start, but mapping out an approach path is crucial to avoiding costly mistakes later. ![]() You’ll want to take a minute and think through what you’re going to need. The first step to building a good data model is usually not on the computer. We will be doing some data modeling and putting your active record knowledge to practice by building your own light weight Reddit clone. In this project, you’ll get to spend some quality time with models. ![]()
0 Comments
Leave a Reply. |