More than one enum in a class asp.net - asp.net-mvc

I am creating an events class for an application, the event has different categories for which a participant can sign up for e.g if they are a veteran cyclist or a master cyclist. In addition, an event can be seeded or not as well, would it be advisable to have two enums one for the categories and one for the event being seeded or not, or is there a better way to do it?

Related

Designing a Database Schema - Data that is common to all users or custom made

Hi I am working on a calendar application using Ruby on Rails. Rails is database agnostic, so in development I'm using SQLite but in production I am looking to use PostgreSQL.The current obstacle that I am facing is with the way I am designing my database schema.
First I have a users table that holds information such as login info and email. Each user has_many plans.
Then I have a plans table that belongs_to users and each plan has an event it references, the date, start time, and end time.
So the plan tables would reference the events table.
Here is my issue:
I would like to have two event tables. One is custom events. The other is default events.
The default events is just a list of common events already defined so the user can already select from a list. The custom events table is a list of events created by a user that references their id.
Here is my solution:
Would it be sufficient to add a new boolean column to the plans table called "custom". And if it is true then the event_id (in plans table) will reference the custom events table, and if it is false then it will reference the default events table. Is this a valid solution and if so, how would I implement it into my Rails application?
Thank you for taking your time to read my question. I am sorry I am an idiot. I am practicing everyday to be better.
Try to not think in terms of tables first, but in terms of classes and the behavior of their instances. What would matter most in the end is not how many tables your design has, but whether the responsibilities have been correctly attributed to the different classes in your model.
In this case it looks like you need two different classes, because some events will belong_to a user and other won't. The former will be created, modified and deleted by that user, and the latter will be managed by an admin. The instances of those classes can be stored in the same table using STI (Single Table Inheritance), with a string column named 'type' to enable Rails to store the class for each instance. The UserEvent class will belong_to :user, and the DefaultEvent won't. Both classes can extend Event, which in turn extends ActiveRecord::Base.
Please let me know if you need additional clarification.

Best way to manage Data with Parse?

I am creating a social app and will be handling large amounts of data. I have a certain part of my app where you can create four different types of events. My question is, would it be better to separate these four types into different classes: eventType_One, eventType_Two, eventType_Three, and eventType_Four to create smaller queries?
Or should I put all the events into one class events, therefore only creating one API request instead of four. On several pages I need to query through each class. I also will only have the basic plan: 30 requests
I'd create a class EventType and an Event having the EventType as a relation. So you fetch the available types once and then your desired events. You want to limit the number of API calls as much as possible to a) not exceed your free plan and b) have fewer requests on the client side.
I have created a similar social app and I modeled it after parses AnyPic. Parse uses 1 Class Activity which handles activities like: likes, comments, and follows. You can add your own events/activities to it if needed. Checkout AnyPic
If you need to do something like photo, video, or galleries, I would recommend turning the photo class into a post class and adding a type field. Either way using the AnyPic model you should be able to add activities/events as needed.

Common identifier for multiple models in Rails

I'm developing a simple app for creating and managing events such as birthdays, weddings etc. All of the different events have different attributes and could be very different. I'm a beginner in rails but I've done the Rails for Zombies course so I know how to create models/controllers. However, I'm stuck now when I want a common identifier for all the events, like a key. It should be possible to search for events using a code/identifier and I don't know how to do this.
I was thinking of having an Event model which would contain the identifier, ex 'JamesBDay'. Then each of the different event model (Birthday/Wedding etc) would keep it's respective Event model. Am I thinking right and how do I do this using Rails 'generate' and 'db:migrate' commands?
And when this is accomplished, how do i search for any type of event using the identifier in their Event attribute?
An explaining picture below
Thanks!
This sounds like a perfect problem for Single Table Inheritance. Essentially you would have a user that has_many events. Create an events table and add a field called "type". From there you create other models that subclass "Event" and NOT "ActiveRecord::Base". These will all be stored in the same table, but will be unique objects that can have their own methods. This allows you to parse through the events as an entire list "Event.all" and then find out the type there, or you can parse through individual event types with "Wedding.all".

STI + namespaces

I need to be able to schedule reminders for users. So I thought I could just create a base model Reminder and use STI to make descendant classes which override the function fire(), called when reminder fires. But different user roles have similar types of reminders. So they need to be namespaced, e.g. Adult::BrushTeethReminder sends an email to user, Kid::BrushTeethReminder posts on kid's FB wall.
Is it possible with STI and how if yes?
Other way I see is to just prefix model names like KidBrushTeethReminder. Or go even deeper - write a factory method which creates objects according to type. Or is there a cleaner way?
I see two types of reminders, one for adult and one for kid. Personally, I would use an STI called Reminder and have one model called BrushTeeth inherit from Reminder. In the BrushTeeth model, I would have two Boolean columns named for_adult and for_kid.
In your Namespace for Adult, you can check BrushTeeth by querying whether the for_adult column is set to TRUE and base your logic / implementation from there. And for the Kid Namespace, you check the for_kid column.
Having Reminder as the base, gives you the option to have other reminders easily (i.e. Shower, Bath, Nails, etc). The Reminder model also comes with a Type column, since this is an STI model.
Hope that helps.
I found that you do can use STI for models in different namespaces. You just need to place them in appropriate subfolders. For example, Kid::BrushTeethReminder should be placed under app/models/kid in file brush_teeth_reminder.rb

How to handle multiple user types in Rails?

I'm finding a good way to modeling User different types in the system. For registration, he/she can select to be a student, a mentor, or both. Being a student or a mentor has different set of properties. Student and mentor will have different profile template layout as well.
How would you design your controllers and models for this kind of problem?
I would create a User which can hold a Mentor class and/or a Student class. This way your different properties are seperated from each other while the same properties still remain in the User class.
In the Controller you can render a template (or partial), depending on the instance the User holds. One for students, one for mentors and one for both.
You could also use Inheritance (User as parent with Mentor, Student and Both as childs). The key word you want to look into here is Single Table Inheritance.
Imho the problem is the both option. That's why I would prefer the 1st solution.

Resources