Relational Entity with one Model Class - asp.net-mvc-4

I am facing Problem with Entity Framework with MVC 4 .
Let me put the Table Structure and result which i needed.
as you can see i have three table and the data structure is
can anyone suggest me how can i write Model class so that on create country page i have layout like
select Language -- Language Dropdownlist Box here
Enter Country name- country text Box here
Thanks
Ashutosh

As already said, you have problems with your table structure, and a model will reflect this, not correct it. And while I am at it, German and Chinese are languages, while Germany and China are countries.
Country Names should be in Countries table, while country_languages is a table allowing a many to many relationship and as such should never be seen by your end user.
If you define your model properly with only Countries and Languages, Entity Framework with Code First will generate a correct Countries_Languages table for you.
Don't forget that in some countries, more than one language is spoken, like Switzerland which has 4 official languages....

Related

how to add dyanmic parent child relationship in jira custom field?

I am trying to migrate some of my bugzilla data to JEERA. I have some custom fields in bugzilla which has dynamic parent-child relationship. for exa-
Suppose I have Labels "India" "China" "Russia",
when I click on Label lets say "India", then it should fetch and show only cities from India and not all cities.
Right now , I am able to create Labels and cities custome fields in jeera but lacking dynamic nature.
I will be thankful, if anyone has any idea over this.
Perhaps Select List (cascading) custom field type would best solution here.
As a bit workaround for relate two custom fields between each other you can use ScriptRunner Behaviours. It's like a Groovy definition for frontend logic. Conceptually:
City field must contains all Cities for all Countries.
Create a Behaviour for a Country field. It means when user will change/select a Country field a Behaviour will be run.
In behaviour write code that will get currently selected country and then fulfil a Cities field based on selected country.
Useful methods: getFieldById(fieldId), formField.getValue(), formField.setFieldOptions(Iterable). API Documentation.
I think #sintasy is right.
If you want N-countries have their own cities, cascading select list just fit your requrement.
If you want N-countries * M-other-things, which have no relation with countries, two select lists will fit your requrement.
If you want more complex feature, then I don't known.

how to fix spelling mistakes in a database have multiple records in that records there are more records

i have a database having country, city, state and hotels in these table country name has multiple identical records for eg mexico is wrongly spelled as maxico and mxico and mexico,other records like usa and united states of america and america these type of records are having mutiple same wrongly spelled states and states has multiple wrong spelled cities but hotels are unique and i want them to set them to there right city and state and country for eg. some hotel is in chicago city Illinois state and country is usa. please help me how can i fix this
you could do an update if you know all the different scenarios that are incorrect
update tbl
set city = 'Mexico'
where city in ('maxico', 'mxico')
Well,you can list all values the country column has,and then check wether the values is right, if it is wrong, just use update clause to fix the wrong value, like below:
update my_table set country = 'Mexico' where country in ('maco', 'xico');
It depends on infrastructure you're running.
If you have access to some ETL tools, they often have DataQuality capabilities, often with databases used in correcting adresses. Those are often paid.
If you are a "private" developer, then you might not want to use paid data, so you can look for open data sources, like https://catalog.data.gov allegheny country addresses.
You can use multitude of algorithms and solutions, ranging from simple distances in word space to neural networks pre-trained to do just that.
This type of data problem is hard. There is no built-in simple way to determine the "right spelling". Many databases have one of two capabilities built in that can help -- either "soundex" algorithms or Levenshtein distance.
What should you do? If you really want to fix this problem, create a table with the misspelled name and the correct value that you want. This table will need to be maintained manually, such as in a spreadsheet. Then use this table when importing data and use only the rectified value.
Better yet, set up a reference table with only the correct names. Create a second table with alternative names, which is maintained as above.

Localize member caption in Mondrian schema

Is there a way how I can localize captions of members in Mondrian schema? I know I can localize names (captions) of cubes/hiearchies/dimensions/levels using localizing schema processor, but I do not see a way how to localize names of individual members.
Suppose we have dimension named product with list of products. Our current structure is that for every descriptive column we have translation, something like:
product_key
product_group_en
product_type_en
product_name_en
product_group_cs
product_type_cs
product_name_cs
Is there a way how I can map these columns to schema so correct language is displayed based on user's locale (en/cs/default)?
Our current solution is to have two hierarchies (one for each language) in every dimension, but this is not very elegant.

Localisation of country names

As part of addresses I am storing in my SQL database country codes (e.g. US, DE,...). I then have another table (with two columns) in my database which translates the country codes to the English language names of the respective countries.
If I want to make the site multi-language, I could expand this translation table adding country names in other languages than English.
I was wondering if there is another method which does not involve modification of the database, e.g. using gettext to translate the English country names?
The typical way to handle this is to change the table structure to have three columns, instead of two:
Language
CounryCode
FullName
Whenever you query the database, you would provide the current language.
You then have to change your code to include the additional language key in any queries.
Depending on how you are going to keep track of the current language, you would also use a view or user defined function.
You don't want to use automated translation, since the name of a country like "China" could turn into the equivalent of "porcelain".

How to name my enum elements?

I have a problem naming the elements in my application's data model.
In the application, the user has the possibility to create his own metamodel. He does so by creating entity types and a type defines which properties an entity has. However, there are three kinds of entity types:
There is always exactly one instance of the type.
For instance, I want to model the company I am working for. It has a name, a share price and a number of employees. These values change over time, but there is always exactly one company.
There are different instances of the type, each is unique.
Example: Cities. A city has a name and a population count, there are different cities and each city exists exactly once.
Each instance of the type defines multiple entities.
Example: Cars. A car has a color and a manufacturer. But there is not only one red mercedes. And even though they are similar, red mercedes #1 is different from red mercedes #2.
So lets say you are a user of this tool and you understood the concept of these three flavors. You want to create a new entity type and are prompted to choose between option 1, 2 and 3. How would you name these options?
Edit:
Documentation and help is available to the user. Also the user can be expecteted to have a technical/programming background, so understanding these three concepts should be no problem.
First of all let me make sure I understand the problem,
Here's what you have (correct me if I'm wrong):
#of instances , is/are Unique
(1,true)
(n,true)
(n,false)
If so,
for #of instances I would use single \ plural
for is\are unique (\ not unique) I would use unique \ ununique.
so you'll get:
singleUnique
pluralUnique
pluralUnunique
That's the best I could think of.. I don't know exactly who are your users and what is the environment, But if you have an option of adding tips (or documentation) that should be used for sure.