0

I'm working on a system which predicts soccer matches at work. I have several pre-existing databases which each contain broadly the same data, although some vendors provide more data than others. I have a core set of fields that my application uses and which all vendors provide:

homeTeamId, awayTeamId, fullTimeHomeGoals, fullTimeAwayGoals, homeShotsOnTarget, awayShotsOnTarget, etc...

Because these databases have come from different sources the field-names vary. Also some of this data is subjective (the definition of a shot on target varies). This means that I need to know which vendor a match came from. There is also overlap because several vendors will have the data for a particular match.

At the moment we are using one source of data at a time, but we will use two or more vendors at once based on the competition covered by that vendor in future (by selecting based on competition we remove the issue of duplicate matches).

My solution was to use XML to store a mapping of the fieldName. E.g

<Schemas>
    <Schema>
        <SchemaName>VendorA</SchemaName>
        <TableName>VendorA_MatchResults</TableName>
        <FullTimeHomeGoals>homeFullTimeScore</FullTimeHomeGoals>
        Etc...
    </Schema>
</Schemas>

Then whenever I need a field for a sql query, look at the vendor the user has specified in the job configuration XML and lookup the fields relevant to that data vendor. When we come to uses results from two vendors I was planning to use a view and treat this as a new vendor in the XML.

This must be a reasonably common problem but I couldn't find anything online discussing how to tackle it. My gut instinct says the DB should be able to handle this internally instead, perhaps with a view?

I'd be grateful for any advice or ideas.

For background, I'm using MySql and Java to develop this application.

1

1 Answer 1

0

I think what you are doing is good.

You should create a class which stores these configurations for each schema. Store these configs in a Map. Make sure that these entries and their configurations come from a config file, just like you did.

I would recommend Spring here, it makes your life easier. Each time when you want to add a new vendor, you just need to edit this config file, and restart your app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.