Sie sind auf Seite 1von 124

Task 2: Data Modeling

List of articles

article no. article provider no. provider price €


4711 Radkappe "Alu" 0001 Kemper GmbH 159.00
4711 Radkappe "Alu" 0002 Franz M. AG 161.00
4711 Radkappe "Alu" 0003 Dieter G. GmbH & Co. KG 158.50
4712 Radfelge "Stahl" 0001 Kemper GmbH 105.00
4712 Radfelge "Stahl" 0002 Franz M. AG 99.00
4712 Radfelge "Stahl" 0003 Dieter G. GmbH & Co. KG 102.00
4713 Scheibenwischer "M-Benz" 0002 Franz M. AG 19.00
4713 Scheibenwischer "M-Benz" 0003 Dieter G. GmbH & Co. KG 21.00

Questions (Estimated preparation time: 0,5h)

Q1 What kind of problems or disadvantages may occur in the handling/maintenance of this list (imag
Q2 Create a better data model for these pieces of information.
Q3 Explain, why your data model is better than the original list.
Q4 Once your better data model has been established, create an SQL query that generates the orig

Please anwer the questons Q1 - Q4 on the sheets Q1 - Q4


list_articles

nce of this list (imagine, that a real world list like this would contain thousands of entries)?

generates the original list again.


What kind of problems or disadvantages may occur in the handling/mainte

Redundancy in table may lead to more disk storage consumption and very fast growing of the table,
to look over records in big-sized table takes great time
Unnormilized table also may have negative effect for writing records into the database
Using strings as key for indexing and access may lead to slow perfomance
he handling/maintenance of this list (imagine, that a real world list like this would

growing of the table,


rld list like this would contain thousands of entries)?
Create a better data model for these pieces of information

Orders
PK+index FK
id article_key price_€
1 1 159.00
2 1 161.00
3 1 158.50
4 2 105.00
5 2 99.00
6 2 102.00
7 3 19.00
8 3 21.00

Articles
PK+index
id article_no
1 4711
2 4712
3 4713
ese pieces of information.

FK PK+index
provider_key id
1 1
2 2
3 3
1
2
3
2
3

article
Radkappe "Alu"
Radfelge "Stahl"
Scheibenwischer "M-Benz"
Providers

provider_no provider
0001 Kemper GmbH
0002 Franz M. AG
0003 Dieter G. GmbH & Co. KG
Explain, why your data model is better than the original list.

Normalizing DB schema gives better perfomance (as far as writing or inserting new values in DB are co

Also this schema reduces storage space on the disk (exclude redundancy)
Indexing also should be created on the keys. All keys should be numeric (not string!) BIGINT unsigned

This can give better access time results, when looking over billions records.

This schema also can be easily partitioned for example by date, also sharding can be used.

For further steps it can be integrated to replicate into Clickhouse archive (for example)

As far as billions records are concerned it is not only design schema table is under consideration, but m
mysql server should be configured in a rigth way, using special tools and technics and solutions
oncerned)

d for example
Once your better data model has been established, create an SQL query
SELECT c.article_no, c.article, b.provider_no, b.provider, a.price_€
FROM usersdb.orders AS a, usersdb.providers AS b, usersdb.articles AS c
WHERE a.provider_key = b.id AND a.article_key = c.id;
ate an SQL query that generates the original list again.

Das könnte Ihnen auch gefallen