foreign-keys

Relationship to different tables in SQLalchemy

痞子三分冷 提交于 2021-02-19 06:57:25
问题 I have multiple tables. All tables have multiple columns that could not logically be stored in one merged table. class Foo(Model): foo_id = Column(Integer(unsigned=True), primary_key=True, nullable=False) foo_data = Column(...) class Bar(Model): bar_id = Column(Integer(unsigned=True), primary_key=True, nullable=False) bar_info = Column(...) class Baz(Model): baz_id = Column(Integer(unsigned=True), primary_key=True, nullable=False) baz_content = Column(...) Now I want to save changes in a

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

Foreign key reference target does not exist

我们两清 提交于 2021-02-10 16:57:22
问题 I need to synchronize data in two tables from different Firebird databases. Precisely, I need to update records in table Person (1st DB), using records from table Users (2nd DB). Not only "name", "email", "birthday", but ID also (!). The problem is - there are tables, that depend on Person's IDs through FOREIGN KEY Constraint. I'm trying to do this: Drop Foreign Key constraints in dependent tables. Sync two tables (which means renewing/changing IDs in table Person) Change appropriate IDs in

How do you ensure values from a logging table match objects in other tables ?

試著忘記壹切 提交于 2021-02-10 16:18:51
问题 I have three tables. Two basic tables listing objects and a third table logging changes in database. Here is an example. create table individual (ind_id integer, age integer, name varchar); create table organisation (org_id integer, city varchar, name varchar); create TABLE log_table (log_id integer, object_id integer, table_name varchar, information json, log_date date); I want to ensure that any row in the log_table corresponds to an existing object in either the individual table or the

How do you ensure values from a logging table match objects in other tables ?

☆樱花仙子☆ 提交于 2021-02-10 16:17:39
问题 I have three tables. Two basic tables listing objects and a third table logging changes in database. Here is an example. create table individual (ind_id integer, age integer, name varchar); create table organisation (org_id integer, city varchar, name varchar); create TABLE log_table (log_id integer, object_id integer, table_name varchar, information json, log_date date); I want to ensure that any row in the log_table corresponds to an existing object in either the individual table or the

How to search two tables sharing a foreign key (I think I'm asking this right…)?

旧城冷巷雨未停 提交于 2021-02-10 14:21:06
问题 Dog entity @Entity(tableName = "dog_table") public class DogEntity { private int mId; private String mName, mBreed; etc.. } Toy entity @Entity(tableName = "toy_table") public class ToyEntity { private int mId; private String mName, mBrand; etc.. } DogAndToy join table entity @Entity(tableName = "dog_and_toy_join_table", primaryKeys = {"mDogID", "mToyId"}, foreignKeys = { @ForeignKey( entity = DogEntity.class, parentColumns = "mId", childColumns = "mDogID", onDelete = ForeignKey.CASCADE,

ValueError on foreignkey default value

白昼怎懂夜的黑 提交于 2021-02-10 05:39:50
问题 I deleted my db.sqlite3 and the file on my migration folder except __init__.py but including the __pycache__ folder. My app's models are multiple files in a folder with an __init__.py file with some import and an __all__ variable (I don't know if this matter). From the prompt I give the first migrate command and it look to work (migrating sessions, admin, auth, registration, contenttypes. There isn't my app 'core'). So i give the first makemigrations command and again the migrate command.

Storing “redundant” foreign keys to avoid joins

纵然是瞬间 提交于 2021-02-08 10:13:10
问题 I'm designing a database for a web application project and I came to the conclusion I may have few queries that will require a lot of joined tables to just make one check. I'm wondering how bad is it to store the foreign key somewhere on the way to decrease number of joins required for these queries? To give you an example of what I have at this moment: Service => Booking => Transaction => Wallet => BonusOffer I need to check whether the service has been bought with wallet associated with a