Creating Db relationships Entity Framework - sql-server

I have a new website project (part portfolio, part self-teaching) for creating and storing recipes. I've sketched out a number of tables that I think will serve as a starting point. I'm not certain the best way to relate them to each other along best practices with Entity Framework database first design. Once I have good relationships set up I would like to use this in an ASP.NET MVC application that I am also building.
Recipes - One recipe contains many steps, one recipe contains many ingredients, one recipe has one meal category
RecipeSteps
Ingredients - One ingredient belongs to one food group, many ingredients belong to many recipes and recipe steps
Food Groups - One to many with ingredients
Meal Categories - One to many with recipes
Measures
I'm using SQL DBM beta to create diagrams of the relationships
The PKs right now are datatype bigint, I don't know if this is a good idea or not.
Please reference the link below for a diagram.
https://sqldbm.com/Project/SQLServer/Share/CWVyMDaQBmjz2hb_hWrslw

Related

EDR M:N relationship with multiple dependencies

I am in process of designing a reporting tool. the Interface will be C# with backend database. The tool will allow to enter and edit data through an interface and save it to the Database. Additionally, it will provide specific reports, based on the data retrieved from DB.
Currently, I have been trying to solve a M:N relationship in for my DB tables.
The tool lets a user to enter daily Item amounts (Steel and Mesh) based on a Project. I have solved the M:N relationship in the following diagram but I am not sure if this is actually possible and whether I need to break down the daily stats table further, due to a composite key containing 4 PKs from other tables. This is the current diagram i got.
I am wondering whether the diagram has solved the M:N relationship correctly and whether there is a better way to utilise the date table.

How do I do convert a relational data model into a NoSQL document store type data model?

I'm developing an attendance taking application where students can scan a barcode to verify attendance. At the most basic level, I have thought of creating students, classes, and attendance tables. students and classes will have a many-to-many relationship which is why I introduce the attendance table.
For my use case, I'm thinking of generating a new barcode every day of the class, for each class. I'm using Firebase for this project and this is my first experience with a NoSQL database which is why I'm having a difficult time modeling this type of relationship. I'd appreciate your inputs on the possible ways how my database should look like.

3-Way Relation or Relation with Relation in Laravel?

I'm puzzling over how to set up this relationship in Laravel, (I'm converting a legacy app):
I have Repair Shops, which provide different types of repairs, on different brands of vehicles.
For example, Shop A might repair Brakes but not Exhaust Systems for Ford vehicles. Shops are required to say what services they provide, (Exhaust repair), but adding a brand is optional. I have Shop, Service, and Brand tables in the DB. Shop and Service have a belongsToMany relationship using the provides_service pivot table. In the legacy system I have a 3-way pivot table to specify what Services can be done to each Brand in each Shop.
Laravel doesn't seem to do 3-way relationships well, (or does it? If so, point me there!). So, I feel like it would make sense to create a belongsToMany between the provides_service relation and the Brand. So, is there a way to set up a relationship between a Model and another Relationship in Laravel, or do I have to create a ProvidesService model? Creating a ProvidesService model seems wasteful, but I'm not sure what else to do here.

Data model, many-to-many and one-to-many relation

So we are developing a KPI and Initiative management system for a client.
In the image you can see the data model we've built based on the client's needs.
Basically this is the hierarchy of our data model: Strategic Objective linked to one entity > KPI > Initiative
Recently we've discovered from the customer that the strategic objective and KPI could be shared between more than one entity, but in the end for each entity there is a different Initiative.
I don't know how to reflect this in the data model. But I came up with three possible solutions:
1- Breaking down the Strategic Objective and Entity relation from one-to-many to many-to-many. And also the Strategic Objective and KPI relation to many-to-many, but this does not solve my problem. As in the end I want to model that for example SO1 is shared between entity1 and entity2, so is the KPI but not the Initiative.
2- EntityOwner table, that basically maps the Strategic Objective or KPI or Initiative to the entity directly.
3- Instead of mapping the entity to the strategic objective, we map it to the Initiative.
The Datamodel
Why not remove the relation between the KPI and Initiative and instead create one between Entity and Initiative?
Such model resembles the fact that KPIs seem to be in the domain of business performance while initiatives lie more on the side of programmes / projects office. In other words a business creates initiatives to satisfy strategic objectives not KPIs. KPIs are for visibility.
I would also query whether Strategic Objectives should have direct relationship with Entities, or whether there should be relationship SO -
- INITIATIVE -- ENTITY.

Creating an entity relationship diagram

I've created this ERD:
But now I want to add some more information to my diagram, but I do not how I should do that.
I want to modify my previous ERD, I need to register what recipe was made by what chef in each program. Also, I want to identify what ingredient and tool were used in each step of the recipe.
I think implementing your Entity Relationship Diagram into Microsoft Access can be a good start. You've clearly defined the relations between each entity and have declared attributes for each entity. I would say that you first make each entity into a table in MS Access then add the fields and set up the relationships and see how the work together.
Make sure that your relationships are working before you start filling the database with records.

Resources