I
I
iXelper2020-01-28 19:03:45
MySQL
iXelper, 2020-01-28 19:03:45

How to work with a large number of tables?

Kind time of day, there was a task to compare some tables. In such a way that it would be possible to understand where the products coincide and get their difference.
- What is the best to use? json, dictionaries, etc.
- What is the best logic to organize? the speed of work is also important

Auchan store:
1. Bread: retail = 2; wholesale=1
2. Cheese: retail=4; wholesale=2.5
3. Milk: retail=3; wholesale=2
Shop Green:
1. Bread: retail=2.3; wholesale=1.5
2. Flour: retail=4.2; wholesale=2.7
3. Sausage: retail=2.8; wholesale = 1.8;
Shop City:
1. Flour: retail = 2.2; wholesale=1.3
2. Bread: retail=4; wholesale=3
3. Cheese: retail=3.4; wholesale = 1.9

Result!
Bread:
ashan city: retail=2; wholesale=2
green city: retail=1.7; wholesale=1.5
Auchan-green: retail=0.3; wholesale=0.5

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2019-05-03
@Kozack

A separate table with a list of relationships.

I
Ilya, 2020-01-28
@sarapinit

Making a class:

class Entry {
  string StoreName;
  string ProductName;
  decimal RetailPrice;
  decimal BulkPrice;
}

put all the entries into a list and use LINQ to sort as you need:
List<Entry> list;
//заполнение списка
var sorted = list.GroupBy(e => e.ProductName).ToDictionary(e => e.Key, e => e.OrderBy(k => k.RetailPrice).ToArray());

the result is a dictionary in which key = product name, value = array with records sorted by retail price.
What are your tables?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question