Multiple tables with different properties in a single Azure Search index - azure-cognitive-search

Say I have multiple tables like News and User. These tables have complete different properties, is it possible to get data from both tables in the same index?

Yes, you can index data from different sources into the same index. Here's a tutorial on how to achieve this: https://learn.microsoft.com/en-us/azure/search/tutorial-multiple-data-sources

If you are creating your index programaticaly then just create new ViewModel that is composed of multiple models and create the index out of it. Or create the composite view in database out of few tables and again just create the index based on that view.

Related

Asp.Net core Deleting an entry from table in database: what is the outcome

I have a database with table Photos and table Categories. Each photo is related to one category by categoryId field.
What happens when I delete one category from Categories table? Will the photos with that category be updated with a null value in the categoryID? Or how will entity-framework react to this change?
Another question can I then reset with a mass-change the values of those categories in the photos table? And how can I do that?
hi if you have created relationship between table(using foreign key) then only the deletion of parent table will affect deletion of child table. if you just created table separately and managing relationship with your code then it will not affect the child table. if you are creating using model first approach in entity framework with specifying relation then relationship will be automatically created in backend.
their are four options available in sql on deletion of parent entity
1)No Action
2)Cascade
3)SET NULL
4)SET Default
to know how it will affect check this article
https://www.mssqltips.com/sqlservertip/2365/sql-server-foreign-key-update-and-delete-rules/
That would depend completely on how the ORM that is used defines the database model.
Assuming you use Entity Framework then you can define exactly how EF should react to that situation. In the DbContext you should find a OnModelCreating method in wich you can specify per table what restrictions you want on the table. There you can also define the behaviour of the OnDelete of a foreign key.
If you are not using EF but have your own or a different ORM then again, it depends on how that ORM is configured.
Simple check if you dont know about the used ORM is this: Does the field in the database have a foreign key and how is that configured? Also, is the field categoryID (as defined in the database) nullable? if so, then it apparently doesnt need the relation and shouldnt result in related deletes.

How to implement a Role Play Dimension into Data Vault

I have a data model based on a star schema. It stores three date elements. I integrated them into one role play dimension to avoid redundant dates. I would like to store my data into a data vault model in the core DWH and show the star schema as a view. But right now, im not sure how to handle the problem with the role play model. Should I implement three separate Hubs and Sats fpr the dates? and put them together in the View Layer? or can i implement one date hub + sat and reference them to the link table three times (to the three different dates)?
best regards
I consider the dates as reference table. I have draw a logical model If i understood your problem correctly, Then next logical model would be a possible solution on how to use the same in Hub satelitte or link satellite.
A Role playing Dimension or you could have 3 views on this dimension :
Solution :
Note: This is logical model, So "NO" physical foreign keys.
Dan's Definition of "Reference tables" are referenced from Satellites, but never bound with physical foreign keys. There is no prescribed structure for reference tables: use what works best in your specific case, ranging from simple lookup tables to small data vaults or even stars. They can be historical or have no history, but it is recommended that you stick to the natural keys and not create surrogate keys in that case.[20] Normally, data vaults have a lot of reference tables, just like any other Data Warehouse.
https://en.wikipedia.org/wiki/Data_vault_modeling#Reference_tables

TPT entities derived from TPH base classes in Entity Framework 6?

I have a project that is using EF6 Database first mapped to a SQL database. This is all new so I control the EF model as well as the database schema.
I currently have a table that I'll call Vehicle for simplicity. I use a discriminator column to get subclass Entities Car and Truck. This all works fine.
Now I need to do a 'soft delete' and move any deleted vehicles to a VehicleHistory table. (After trying this w/ EF i will probably use a SQL transaction). This needs to be reviewable so I need this history table mapped as well, but I would like to keep it within the inheritance hierarchy so its easily reused in other classes.
My idea was to create 'vehiclecurrent' and 'vehiclehistory' tables with FK's to Vehicle for shared columns. i would then use TPT in EF to get 'carcurrent','carhistory', ect... derived from my TPH classes(so e.g. carhistory->car->vehicle). This is not working and I get Error 3034: "Entities w/ different keys are mapped to the same row"
So my question is basically how can I pull this off? Will this approach work and how, or is there another way to accomplish this? Thanks!

Displaying fields from related tables in a Silverlight datagrid

I have a Silverlight 4.0 application that has a normalised database. In this database i have tables for Applicants, Licences, LicenceClasses, LicenceTypes and LicenceStatuses amongst others. The last 3 mentioned tables are lookup tables linked to the Licences table through foreign key relationships.I am using RIA services with the Entity Framework for data access. The scenario i am facing is as follows.
When i create a datagrid on my form i get all the appropriate colums with fields from the Licences table. I want to display the names from the lookup tables that are represented by the ID fields in the Licence table. I need to show for instance the LicenceStatus instead of the LicenceStatusID.
I have followed some examples about including the related collections in my domain service and making all the appropriate Include annotations in the Metadata classes. While i can correctly get this to work with one lookup field , i can't seem to find a way to include more than one look up table in my GetLicences query.
public IQueryable<LearnersLicence> GetLearnersLicences()
{
return this.ObjectContext.LearnersLicences.Include("LicenceClass");
}
In the above query i can only include the LicenceClass collection and i have found no way of including the LicenceStatus collection or multiple look up collections that i need to display.
How do i go about accomplishing this
You can include multiple tables by adding a include for each.
public IQueryable<LearnersLicence> GetLearnersLicences()
{
return this.ObjectContext.LearnersLicences.Include("LicenceClass").Include("LicenceTypes");
}

Database Design: Why do some ecommerce database have separate tables for products and product_variants?

Why do some ecommerce database have tables:
product
product_variant
Why not only one product table with all teh fields of product_variant and is_default_product(bool) field?
Thanks
This is called Slowly Changing Dimension
There are some approaches to implementing it which have their benefits and drawbacks.
Solution with two tables allows easier referencing to products (as opposed to product versions) from other tables.
If you have only one table, you have to modify your database design if you want to add product attributes. So if you are tracking colors and sizes in your table, and you want to add, say, inseam, you have to add a column to the table.
Keeping a separate table of attributes allows you to easily manage your attributes as entries in the table, rather than have them be a part of the actual design.

Resources