Coder Social home page Coder Social logo

Comments (5)

longngng avatar longngng commented on June 17, 2024 1

It is just a legacy thing in the dataset I am working with. Thanks for the suggestion!

from sdv.

npatki avatar npatki commented on June 17, 2024

Hi @longngng, unfortunately primary and foreign keys are not supported for custom constraints.

We have added this info to the custom constraints docs and FAQs.

From looking at your code, it seems like the foreign key that you have is a deterministic combination of both the letter and number columns. Since the letter and number columns can be completely recreated from the foreign key, I would consider dropping these columns even before you bring the data into the SDV. You can recreate these columns yourself after you have sampled synthetic data.

from sdv.

longngng avatar longngng commented on June 17, 2024

I see. What if the other columns in data_2 have some more information that I would like to keep? For example

data_1 = pd.DataFrame({
    'key': ['a', 'b', 'c'],
})

data_2 = pd.DataFrame({
    'foreign_key': ['a', 'b', 'c, c'],
    'letter': ['a_20231212', 'b_20231213', 'c_20231214', 'c_20231215'],
    'other': [7, 8, 9, 10]
})

In this case, I would like to enforce the PK-FK relationship, while using sdtype timestamp on the letter column after removing the foreign_key prefix. Do you have any suggestions for this?

from sdv.

npatki avatar npatki commented on June 17, 2024

In the example above, the 'letter' column seems to be of mixed-type (half foreign key, half timestamp). The easiest solution will be to extract out only the timestamp ('20231212', '20231213', ...). This would be a standard way to denote a timestamp. SDV can model both columns (foreign key and timestamp) if they are represented separately.

I would like to understand your project a bit better though. Why does the 'letter' column contain the foreign key's prefix? Is this standard practice in the datasets you are working with? Perhaps if I could better understand why the database is set up this way, it will help us come up with a solution.

from sdv.

npatki avatar npatki commented on June 17, 2024

No problem @longngng. Happy to help.

I'm closing this issue off as out-of-scope since constraints were not designed to be working with foreign keys. But if we ever come up with a compelling use case for this -- one that cannot be done by some pre-processing -- then we can always open a new feature request to track.

from sdv.

Related Issues (20)

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.