relational-database

Can you move compound keys and/or foreign keys to other tables when normalizing to 3NF (third normal form)

会有一股神秘感。 提交于 2021-02-19 05:18:09
问题 My database design is currently at stage 3NF. The issue that is of concern is the foreign keys and in some cases compound keys. My question is this: Can you move compound keys and/or foreign keys to create other tables provided the attributes associated with the compound keys/foreign keys do not rely on the primary key? I think the answer is yes due to this link: Are Foreign Keys included in Third Normal Form? Best Answer : Just because it's a foreign key doesn't mean it also can't be

Can you move compound keys and/or foreign keys to other tables when normalizing to 3NF (third normal form)

天涯浪子 提交于 2021-02-19 05:17:52
问题 My database design is currently at stage 3NF. The issue that is of concern is the foreign keys and in some cases compound keys. My question is this: Can you move compound keys and/or foreign keys to create other tables provided the attributes associated with the compound keys/foreign keys do not rely on the primary key? I think the answer is yes due to this link: Are Foreign Keys included in Third Normal Form? Best Answer : Just because it's a foreign key doesn't mean it also can't be

Can you move compound keys and/or foreign keys to other tables when normalizing to 3NF (third normal form)

孤人 提交于 2021-02-19 05:17:49
问题 My database design is currently at stage 3NF. The issue that is of concern is the foreign keys and in some cases compound keys. My question is this: Can you move compound keys and/or foreign keys to create other tables provided the attributes associated with the compound keys/foreign keys do not rely on the primary key? I think the answer is yes due to this link: Are Foreign Keys included in Third Normal Form? Best Answer : Just because it's a foreign key doesn't mean it also can't be

sqlite - find recipes that can be made from a set of ingredients

若如初见. 提交于 2021-02-18 17:09:53
问题 Right now I am using sqlite within a ios application, and I want to be able to search for recipes that can be made from a list of ingredients (ie recipes such that are a subset of the provided ingredients) For example: Recipe 1: A B C Recipe 2: A B Recipe 3: C D Recipe 4: A Recipe 5: E Query for ingredients A B C returns recipes {1, 2, 4} Query for ingredients A B returns recipes {2, 4} Query for ingredients D returns {} Currently what I have set up is Table Items name text primary key Table

sqlite - find recipes that can be made from a set of ingredients

为君一笑 提交于 2021-02-18 17:07:33
问题 Right now I am using sqlite within a ios application, and I want to be able to search for recipes that can be made from a list of ingredients (ie recipes such that are a subset of the provided ingredients) For example: Recipe 1: A B C Recipe 2: A B Recipe 3: C D Recipe 4: A Recipe 5: E Query for ingredients A B C returns recipes {1, 2, 4} Query for ingredients A B returns recipes {2, 4} Query for ingredients D returns {} Currently what I have set up is Table Items name text primary key Table

How to get a CSV string from querying a relational DB?

感情迁移 提交于 2021-02-11 15:13:20
问题 I'm querying a relational Database and I need the result as a CSV string. I can't save it on the disk as is running in a serverless environment (I don't have access to disk). Any idea? 回答1: My solution was using PyGreSQL library and defining this function: import pg def get_csv_from_db(query, cols): """ Given the SQL @query and the expected @cols, a string formatted CSV (containing headers) is returned :param str query: :param list of str cols: :return str: """ connection = pg.DB( dbname=my

How to get a CSV string from querying a relational DB?

被刻印的时光 ゝ 提交于 2021-02-11 15:06:03
问题 I'm querying a relational Database and I need the result as a CSV string. I can't save it on the disk as is running in a serverless environment (I don't have access to disk). Any idea? 回答1: My solution was using PyGreSQL library and defining this function: import pg def get_csv_from_db(query, cols): """ Given the SQL @query and the expected @cols, a string formatted CSV (containing headers) is returned :param str query: :param list of str cols: :return str: """ connection = pg.DB( dbname=my

Relational DB in microservices

我的未来我决定 提交于 2021-02-10 15:07:03
问题 I have a monolithic application that currently uses a PostgreSQL DB and the schemas are set up as you would expect for most relational databases with various table data being linked back to the user via FKs on the user_id . I'm trying to learn more about microservices am trying to migrate my python API to a microservice architecture. I have a reasonable understanding of how I'm going to break up the larger app into smaller parts, however, I'm not entirely clear on how I'm supposed to deal

Relational DB in microservices

被刻印的时光 ゝ 提交于 2021-02-10 15:05:13
问题 I have a monolithic application that currently uses a PostgreSQL DB and the schemas are set up as you would expect for most relational databases with various table data being linked back to the user via FKs on the user_id . I'm trying to learn more about microservices am trying to migrate my python API to a microservice architecture. I have a reasonable understanding of how I'm going to break up the larger app into smaller parts, however, I'm not entirely clear on how I'm supposed to deal

Reversing steps, Converting SQL query back to tuple relational calculus?

南笙酒味 提交于 2021-02-09 10:57:37
问题 Not sure it is a correct SQL and would like to work backward converting SQL back to tuple relational calculus to check the correctness. Let's say we come up this query to display the classes where all its requirement classes have been complete by all the participants who finished the introduction. So we have two tables, progress and requirement. where progress: mId (string), cId (string) and requirement: : cId (string), rId (string) all the enrollment are kept in progress and all the