How do i expand an nested odata table - odata

I am unable to expand a nested table that I can navigate to in Excel or PowerBI. For example,
Entity set is a list of schools. One column contains a nested table for students that attend the school.
When listing the schools I get the list of school names. When I add $expand=students i get a list of school names with another column students but each row displays just [] as if there aren't students in the nested table.
https://view.mycompany.com/odata/Schools --- provides list of schools
https://view.mycompany.com/odata/Schools?$expand=students --- only provides list of schools and adds the students column without expanding the table.

Related

How to retrieve all of one table and all joined records in another with the other table's columns in ActiveRecord

I would like to retrieve all of one table and all joined records in another.
I would like to have all columns from both tables
This is extremely simple in SQL
e.g.
SELECT *
FROM students
JOIN teachers
ON students.id = teachers.student_id
How can I do the same in rails?
I've tried variations on
Student.includes(:teacher)
and
Student.joins(:teacher).includes(:teacher)
The join is working, but I cannot access columns from Teacher table
Note that the end goal is simply to be able to create an instance variable in the controller so that I can access both student and teacher data in the view
Student.includes(:teacher) will return ActiveRecord::CollectionProxy which means if take particular object in this collection, it will be Student class object.
Unlike sql query fired and returning data from 2 tables, it does not work same in rails, you get data only from students column which will relate associated record in teachers table because it represent Student model.
You can access further teachers data like,
students = Student.includes(:teacher)
students.last.teacher.name
In above no new query will get fired in database when you call teacher association on object

ios swift uipickerview with 3 columns which have relations

I want to make a uipickerview with 3 columns. But this columns has relation in database.
For example brands are first row. These are BMW,Seat,Mercedes ...
Brand's models are second row. These are 1 Series,2 Series,3 Series for BMW and Ibiza,Leon,Altea for Seat and so Mercedes have its own models. And three column is engine capacity. For example for 1 series 1.4,1.6..., for 3 series 1.6,2.0. And for ibiza 1.2TSI,1.4TSI, 1.6TDI and Leon and Altea and Mercedes' models have their own engine capacity.
In my DB i have three tables. First table is brand(brandId,brand). Second table is model(modelId,brandId,model) and third table is engineCapacity(id,brandId,engineCapacity).
If i have all these brand,model and engine capacity how can i show this relation to user? I mean if user select brand SEAT, second column only shows SEAT's models(Ibiza,Leon,Altea) and then user select Leon and third column only shows LEON's engine capacities(1.2,1.4,1.6).
How can i do this?
Implement the UIPickerViewDelegate method pickerView(_:didSelectRow:inComponent:). In your implementation, if the user changes the brand (component 0) then call reloadComponent(_:) on the model and engine size components, and have the data source methods use the currently selected brand to determine which items to return for models and engine sizes.
(When you first display the picker view, have a specific brand and model selected, and populate the model component with the list of available models for the selected brand, and have the engine sizes component populated for the selected brand & model.)

Related tables, filters and conditions

I have a new table where one of his fields is related to Table Items. I want to place a filter in one of the function fields Item Category pointing register the Item table, but do not know how this dual role. I hope it was not too confusing ..

Create a master-details form using ruby on rails

My case is:
I have a voucher, which has header (date, name, final value) and details which is created from items table.
Items table consist of (goods_id, quantity, price....),
Goods_id is the PK of goods table which has the full information about my stock goods
So, how to create a master form(Voucher) contains Items, every Item related to goods table?
Remaining just as abstract as the question I would suggest to use a nested form with a partial as described in this RailsCast.

Database design for categorized to-do app

I'm trying to figure out what the best (most logical) way of designing this database for an app that will allow a user to CRUD to-do tasks (more or less), however, they're organized into hard-coded categories.
So let's say you're about to go to your favorite department store. You need to hit up the Women's floor and pick up your girlfriend the shoes she ordered, and the matching dress (which is on the completely other side of the store, but on the same floor.) Then, you need to go to the Boy's department for your little brother, and pick up two different pairs of shorts, one pair of pants, and a new pair of shoes.
The Women's Floor and Boy's Department are two examples of categories that the shopping list items will fall into.
So it looks like this:
* Women's Floor
1 Pair Shoes
1 Dress
* Boy's Department
2 Shorts
1 Pant
1 Pair Shoes
So my database design could look like so...
Categories: id, title
ListIndex: id, user_id
ShoppingList: id, listindex_id, category_id, item_id, order, active
Items: id, name, category_id
Categories would be Boy's Department, Women's Floor, etc. Users would not be able to create new categories, but instead, we would predefine the categories
ListIndex would provide a master relation to the shopping list as a whole.
ShoppingList would be the actual shopping list (active would be 0/1, so the user could have a way to remind themselves that they bought the item / put it in their cart.)
Items would have a list of items that are available to put into the to-do tasks. We would categorize these ourselves on the back-end.
Is this the right way of doing it?
Hopefully i understood the description of the problem correctly but i was thinking here's one way you could lay your database and models out. I also don't think you need the ListIndex:
Database Tables
Categories: id, title
ShoppingLists: id, user_id, order, active
Items: id, title
ShoppingListItems: id, item_id, shopping_list_id, quantity
CategorizedItems: id, category_id, item_id
Users: id, name
Models
User:
has_many shopping_lists
ShoppingList:
belongs_to user
has_many shopping_list_items
has_many items, through shopping_list_items
Items:
has_many categorized_items
has_many categories, through categorized_items
(optional: you could query an item for the shopping lists that it is on)
has_many shopping_list_items
has_many shopping_lists, through shopping_list_items
Categories:
has_many categorized_items
has_many items, through categorized_items
My thinking is this --
Individual categories are basically static, that's pretty straight forward.
Shopping lists represent a User's (via the user_id) list of items that will be purchased. The link between an item and a shopping list could take place in a join table called ShoppingListItems where each row links together the relationship between a list, an item, and the quantity.
Items are interesting because in your example an item is something that can actually be in multiple categories. i.e. "pants" can be in boys/girls/men/women and probably pets :(. To support that I think you can use another join table called CategorizedItems that basically lets you query for "items in a particular category" or "categories an item is in".

Resources