Giter Club home page Giter Club logo

Comments (2)

essenciary avatar essenciary commented on June 11, 2024

@PGimenez
You could use this kind of convention where you use the same id for both but it's a bad idea, for multiple reasons:

a) it does not work in real life, with concurrent access (multiple users). When you have multiple users adding rows, the insert operations will run out of sync, becoming very difficult to "reserve" ids.

b) in terms of database design, it's not a good approach - by using foreign keys you can define relationships at database level to trigger cascade deletes and other operations.

c) same goes for what the users expect - most people will understand that there is a relationship by looking at the foreign keys.

d) SearchLight maps to the concept of primary key <-> foreign key with the Relationships API, allowing to set and manage relationships.

As such, we'd be showcasing a non-standard and not good approach to DB design, which is not ideal for a tutorial. Best thing would be to use the SearchLight Relationship API (which is not extensively documented though).

from genieframeworkdemos.

essenciary avatar essenciary commented on June 11, 2024

But if you run a quick initial iteration using this approach, it won't work through the ORM. You'll need to run a query, something like:

prediction.price = model([getfield(house, i) for i in 2:14])[1]
prediction.error = abs(prediction.price - house.MEDV)
prediction.timestamp = string(now())
@show prediction
save!(prediction)

SearchLight.query("
UPDATE predictions set id = $(house.id) where id = $(prediction.id)
")

# then retrieve prediction using the new id, if neede
prediction = findone(Prediction, id = house.id)

from genieframeworkdemos.

Related Issues (8)

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.