M
M
Myshka2017-04-07 01:29:00
SQL
Myshka, 2017-04-07 01:29:00

Need advice on building a database?

Hello :3
We need to design a database of contactless metro cards (RFID tags) for this there are four tables with the following links.
cards table
id_card - card number
cash - current number of trips
station - station where it was last used
time - time of last use
status - working/not working
Table station - all metro stations are listed.
table history_add - history of card replenishment
table history - history of movement of card carriers
4e2523250e44456b8fdd7bf9668e1726.png
Please give advice on how to "normalize data" (bring them to some of the NF). And what else would you add here :3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
entermix, 2017-04-07
@entermix

cards
id (INT), status (BOOL), ...
stations
id (INT), name (VARCHAR), ...
operatioons
id (INT), station_id (INT), operation (INT) (+1/-1, etc), balance (INT), created (INT)...

It will display the last transaction with the card, from here you can get the station ID and the time when the card was used (replenished the account / passed the turnstile)

R
Rsa97, 2017-04-07
@Rsa97

IMHO, a fully normalized form would only contain two tables:

stations (id, name);
events (card, event, station_id, sum, timestamp)

where event: ('activation', 'arrival', 'expenditure', 'blocking', 'return', 'withdrawal')
But here it makes sense to partially denormalize and add the balance field and, if any operations with a blocked card are possible , then the fields state.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question