dictionary tables using nosql approach - nosql

I need to migrate a SQL model to NOSQL, should the dictionary tables be separated in different files and then consume those dictionary tables from my main table?
For example if I have Employee json file and there is a dictionary table, EmployeeStatus, which have these values:
1-Active
2-Suspended
3-Inactive
4-Deleted
Should I save the EmployeeStatusId in my Employee json file or I should repeat the name (for example Active) in each employee json?

Related

User Defined Fields storage in Postgresql

I'm looking at building a system which will include user created fields which will use Postgresql as the database. I've read that the EAV model for this isn't great and that a jsonb column to store the custom fields will be the best route.
I want the user to be able to build their own queries to the data as well so is the best way to go to store the custom field names in a table and store the actual data in the jsonb column, that way when it comes to building the queries the webapp can query the custom fields table for a reference as to what fields are available and their types?
Tickets
ID
WhenCreated
LastUpdated
CustomProperties {JSON B column, key value pairs where the key names will be stored in the custom fields table}
Customfields
ID
FieldName
WhenCreated
FieldTypeID
FieldTypes
ID
FieldTypeName {String, Date, etc}

Alter entity to generate ids for legacy table

I have a legacy (old) table with data in a database. Currently, data is put along with ids, so ids are not generated. I'm going to change a source of data. Data from a new source have other ids. These could clash with ids from the legacy table. So I don't want to use them. I'm going to map this data without ids and generate ids with jpa. Will it work if I change my entity for auto-generation and the id column to auto increment? Which options do I have otherwise?

Entity Framework: auto-generate primary keys after initializing tables

I'm using Entity Framework (6) in a code-first arrangement to create a database and pre-populate it from a set of CSV files. Because the tables are coming from another application, they already have primary keys, and relationships embedded in the data make reference to those keys.
For that reason I've been using [DatabaseGenerated(DatabaseGeneratedOption.None)] when defining these tables, so that the PKs already in place get used.
However, after the data have been imported, I want to be able to add new records to the tables. How do I get the DB to assign new sequential PKs for the new records?

How can I replicate core data model using a traditional relational database?

I have my app using core data with the data model below. However, I'm switching to a standard database with columns and rows. Can anyone help me with setting up this new database schema?
First of all you need to create tables for each of the Entities and their attributes (note I added "id" to each of the tables for relationships):
Routine (name, timestamp, id)
Exercise - this looks like a duplicate to me, so leaving one only here (muscleGroup, musclePicture, name, timeStamp, id)
Session (timeStamp, id)
Set (reps, timeStamp, unit, weight, id)
Now that you have tables that describe each of the entities, you need to create tables that will describe the relationships between these entities - as before table names are in capitals and their fields are in parenthesis:
RoutineExercises (routine_id, exercise_id)
SessionExercises (session_id, exercise_id)
ExerciseSets (exercise_id, set_id)
That's it! Now if you need to add an exercise to a routine, you simply:
Add an entry into Exercise table
Establish the relationship by adding a tuple into RoutineExercises table where routine_id is your routine ID and exercise_id is the ID of the newly created entry in the Exercise table
This will hold true for all the rest of the relationships.
NOTE: Your core data model has one-to-many and many-to-many relationships. If you want to specifically enforce that a relationship is one-to-many (e.g. Exercise can only have 1 routine), then you will need to make "exercise_id" as the index for the RoutineExercises table. If you want a many-to-many relationships to be allowed (i.e. each exercise is allowed to have multiple routines), then set the tuple of (routine_id, exercise_id) as the index.

EF: How to eliminate a joi-table in the model while still respecting relationship among tables in the underline database?

Let's say I have a Database with 3 tables: Keywords, Documents, and KeywordDocuments. KeywordDocuments has only 3 columns, KeywordDocumentID, KeywordID, and DocumentID.
The relationship between Documents and KeywordDocuments is the same as Keywords and KeywordDocuments, i.e. one-to-many.
Watching Julie Lerman's video on EF, she said that we don't need KeywordDocuments's entity in the model. How do I eliminate that entity while making sure that in the relationship will be respected in the underline database?
Thanks for helping
Remove the KeywordDocumentID column from the KeywordDocument table. It will then contain only the foreign key columns from the tables for which it represents a many to many relationship.
Create a new composite primary key on the KeywordDocument table which includes both the KeywordID and the DocumentID columns. This will replace the original primary key that you had on the KeywordDocumentID column - that key would have been deleted along with the column.
A table such as this will not result in an entity being generated in the model. Rather, both of the other entities (Keyword and Document in this case) will have navigation properties based on EntityCollection. Document will have a collection of Keywords and vice verca.