Giter Club home page Giter Club logo

cs327e-wcdb's People

Contributors

cm35498 avatar conrad-vanl avatar jupabago avatar taylor4484 avatar zfarn avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cs327e-wcdb's Issues

Requirement 5

Create, validate with instance and push XML schema

WCDB2.py

First - I started translating the XML to a MySQL schema - you can see what I worked on here: https://github.com/conrad-vanl/cs327e-wcdb/blob/master/SCHEMA.md - please note Types don't correspond to actual MySQL data types as I was tired

WCDB2.py is getting pretty long, but I'm trying to keep everything well organized. The start of the document sets up the global variables and settings, such as MySQL connection info and the DB schemas (if anyone wanted to help in creating the schemas here that'd be awesome!). From there, everything is broken up into small classes. I've tried to add comments at the beginning of each class to describe what it does. Instead of explaining how everything works, I think I'll just show you:

> import WCDB2
> factory = WCDB2.Factory()
# now the database tables have been created and we're ready to import/export XML (i/o not yet completed, but would look like this: factory.import_xml_from_file(filename), factory.export_xml())

# Note: running factory isn't required if you just want to play around with MySQL queries:
> WCDB2.DEFAULT_CONNECTION.query("show tables")
# ^ if this doesn't return any tables, you probably just need to create them: WCDB2.DEFAULT_CONNECTION.setup_database()

# Moving on: I don't have the XML import/export function to MySQL completed yet, but you can still create records by hand:
> crisis = WCDB2.Crisis(crisis_id="Japan_Earthquake", name="2011 Great East Japan Earthquake and Tsunami", startDateTime="2038-01-19 03:14:59")
> crisis.persist()  # persists/saves/stores the crisis to the database
> WCDB2.Crisis.select()  # finds/selects * Crises from database
# [{'crisis_id': 'Japan_Earthquake', 'name': '2011 Great East Japan Earthquake and Tsunami', 'endDateTime': None, 'ecnomicImpact': None, 'crisisKind_id': '', 'startDatetime': '2038-01-19 03:14:59'}]

If anyone has time, it'd be a great help to knock out the rest of the schemas at the top. Like I said, I kind of mapped everything out on the repo in SCHEMA.md, but the Types in those tables don't always correspond to MySQL. http://dev.mysql.com/doc/refman/5.0/en/data-types.html

I also might need help creating the serialization methods that converts from XML to a model / from a model to XML. Maybe not. We'll see.

Lastly: design wise with the schema, here's what I've done:

  • Table names are plural of the relation (Crises table, crisis records)
  • only foreign keys contain the relation name in them (crisis_id, crisisKind_id, etc...and name isn't crisisName or cName or anything like that, just name)
  • based on the XML, any complex type that can occur more then once needs it's own table, otherwise, camelize the path to the element and make it an attribute (thus crazy contactInfoPostalAddressStreetAddress)

Did I mention all this can be up for debate?

Finalize XML Data File Example

File needs to be doubled checked before posting to Piazza.
The location attribute of person is not present on the example file - are we doing a similar coordinate style location seen in crises or should this be country, province(state/region), city?
It would be good to start looking at other common elements that will need id's, such as location, occupation, DOB?, etc.
And we need to finalize the way id keys for orgs/ppl/crises are constructed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.