Sorting Data in Informatics - sorting

I have to create a workflow where I need to make six mappings and then sort the data of these mappings in order. For Example, there is a name, address, and phone number. These data are put into separate files and have different mappings. After this, I need to create another session where a person's name, address, and phone number come together.
Name
address
Phone
Name1
Address1
Phone number1
Can anyone please tell me how to sort the data?
Thanks in advance

Related

Map multiple values to a unique column in Elasticsearch

I want to work with Elasticsearch to process some Whatsapp chats. So I am initially planning the data load.
The problem is that the data exported from Whatsapp, doesn't contain a real unique id per user but it only contains the name of the user taken from the contact directory of the device where the chat is exported (ie. a user can change the number or have two numbers in the same group).
Because of that, I need to create a custom explicit mapping table between the user names and a self-generated unique id, that gets populated in an additional column.
Then, my question is: "How can I implement such kind of explicit mapping in Elasticsearch to generate an additional unique column?". Alternatively, a valid answer could be a totally different approach to the problem.
PS. As I write, I think the solution could be in the ingestion process, like in a python script, but I still want to post the question to understand if this is something that Elasticsearch can do by itself.
yes, do it during the index process
if you had the data that maps the name and the id stored in a separate index you could do this with an enrich processor when you index the data to add whichever value you want to the document via a pipeline
also - Elasticsearch doesn't have columns, only fields

Change report locale for each record?

I have customers from many countries, and for each one I need to generate a page with data on it.
In my report I have a similar query: SELECT Name, Address, CodLanguage ... FROM Customers
For each record of this query, I want to generate a page in Jasper Reports with customer data in their respective language (I know its language through this flag CodLanguage).
I want change report language for each customer page (each record). Can i do this using report parameter locale? Or changing some variable for each record? Has anyone had a similar situation? Have any idea what can be done?
Example
I need translate the labels: Name, Address, City, Phone Number and Country in 10 different languages, according to the customer's country language.
This example is only a simplification. I will generate between 3 and 6 report pages for each customer, with many other data.
Thanks!
As far as I can tell, this is not possible using any of the standard resource references:
$R{resource.bundle.property}
msg() function
str() function
For each record, supply the corresponding locale (or determine it based on other data, like the country and city -- chances are Quebec, Canada would be French [fr_CA] while Toronto, Canada would be English [en_CA]).
Once there's a map of locales to locations, use a ResourceBundle (or MessageFormat?) to translate the key for a particular label.
Create a number of resource bundle files with translations for the various labels. The file names must have a suffix that corresponds to the predetermined locale (e.g., Bundle_fr_CA.properties).
Change the label from static text to an expression. The expression instantiates a new resource bundle to look up the key (e.g., "city.name") for its translated value, such as:
ResourceBundle.getBundle("Bundle", new Locale("en", $F{country})).getString("city.name")
How the "en" is determined will be a bit of a chore, unless you can alter the database to get the user's language preferences. This means you'll also have to create a resource bundle for every language/country combination, which can be automated.

Validate that value is unique over multiple tables access

Scenario: I have to create a database which has to contain 3 different tables holding information about people. Lets call them Members, Non_Members and Employees. Among the other information they may share , one is the telephone number. The phone numbers are unique, each in its respective table.
My problem: I want to make sure the phone number is always unique among these 3 tables. Is there a way to create a validation rule for that ? If not and I need to redesign the database, which would be the recommended way to do it.
Additional info: While the 3 tables hold the same information (Name , address etc.) its not required always required to fill them. So I am not sure if a generic table named Persons would work for my case.
Some ideas: I was wondering if and how I can use a query as a validation rule (that would make things easier). If I would end up creating a table called Phone numbers , how would the relations between the 4 tables would work in order to ensure that each of the 3 tables has a phone number.
ERD
I assume you are talking about a relational database.
I would go for a single person table with a "type" column (member, non_member, ...). That is much more flexible in the long run. It's easy to add new "person types" - what if you later want a "guest" type?
You would need to define as nullable to cater for the "not all information is required" part.
With just a single table, it's easy to make the phone number unique.
If you do need to make it unique across different tables, you need to put the phone numbers in their own table (where the number is unique) and the references that phone_number table from the other tables.
Edit
Here is an example of creating such a phone_number table:
create table phone_number
(
id integer primary key,
phone varchar(100) not null unique
);
create table member
(
id integer primary key,
name varchar(100),
... other columns
phone_number_id integer references phone_number
);
The tables non_member and employee would have the same structure (which is a strong sign that they should be a single entity)
Edit 2 (2016-01-08 20:12)
As sqlvogel correctly pointed out, putting the phone numbers into a single table doesn't prevent a phone number to be used by more than one person (I misunderstood the requirement so that no phone number should be stored more than once)

Validating a users phone number on a global scale using MVC3

Im working on an mvc3 application that will be deployed globally and have a question about phone numbers and validation.
I want to display a textbox that allows customers to insert their phone number correctly based on the machines settings.
I know I can apply all of my regex's onto the model's PhoneNumber field.
If a user is coming from the US vs the UK there are 2 different regexs to be used.
Lets say a US based user inserts an invalid phone number how can I tell the application only to validate the phone number using the US format based on the users culture not against the entire range of regex's?
I dont want the user to be told that his/her phone number is not formatted in UK format as that means nothing to them.
Hope this makes sense.
There are a lot more than two regexes.
For the UK alone there are are getting on for 10 or more different formats for telephone numbers and that doesn't take into account the different ways people can (and do) group the digits as well.
My answer to a different question shows the different formats.
You're best approach is probably to use other data on the form to try to validate the phone number rather than analysing the number itself.

How do you deal with "Many Names for 1 Person"?

One of the most common problems I run into when creating any information system is the fact that people go by so many different names. Someone named "Bill Smith" may go by "Will Smith","William Smith", "Smith, Will", etc... If say, I wanted to write an application to link blog posts to authors, I would have to account for all those names.
My question is: What approaches do you take to keep consistent data throughout your application. How do you structure your database so that you can refer to a single identifier to locate all those names? What UI approaches do you take make sure that people enter in names in a consistent manner?
As long as you have a unique id for each user (which is not their name) you can have a table that maps name variations to a unique id, and then associate each post with that unique ID.
(Table mapping names to UIDs)
Name UID
Robert S 123456
Bob S 123456
Bert S 123456
Darren 987654
(Table with post information, including author's UID)
Title Author ...
Post 1 123456
Post 2 123456
Post 3 987654
(Table with author information)
UID Preferred Name Webpage ...
123456 Robert Smith http://www.robert.com
987654 Darren Jones http://www.jones.com
It's probably a good idea to accept only one name from your user, and allow them a "nickname" or a "public name". That gives them the freedom to have a legal name, perhaps for mailing or billing, and a public-viewable name for interaction on your site.
Beyond that, I don't think I would allow my users to have multiple names, unless my system required it. If I did, I'd split it up into two tables:
Users:
userid (ex: 1821)
UserNames:
userid (ex: 1821)
firstName (ex: Jonathan)
lastName (ex: Sampson)
In addition, you could add a field in the usernames table called 'isPrimary'. This would be a boolean value that will tell you which name to treat as the primary name for the user. This is similar to how wikipedia store a history of data/changes. They keep all, but mark which is "active", or in your case "primary".
It sounds to me like you are trying to use their name as a primary key or UID. This is the wrong way to go. You should have a seperate UID as the primary key, then the name can be whatever you want, and you can even have a list of alternate names.
The real problem happens when you have multiple applications, and each one has their own schema for user information. The billing system might have "Will Smith"; the payroll system might have "William Smith"; the claims system might have "Willie X. Smith". All are really the same person. What do you do? It's a huge issue for stovepipe, legacy apps.
I agree with the first 3 posts on how to structure your schema.
In regards to the UI I would allow a field for the persons legal first,middle and lastname which should change very rarely.
Then allow nickname(s) depending on your application requirements.
Having their full legal name can come in handy for billing/financial/HR situations too.
You could always make a AKA table, where you could have the prefer name to AKA name. So if someone uses the name Bill, you can always replace it with William.
I have never personally used this concept for names, but I do support a project that does something similar with Movie Titles, which can varied for different countries.

Resources