foreign-keys

how to: creating a view and serializer for adding, editing, and deleting objects with foreign relationships django rest framework

旧时模样 提交于 2019-12-08 12:35:37
问题 I am having a very hard time connecting all the documentation on django and django rest framework on how to create a view and serializer that allows for a foreign key. edit: I might have an answer here: http://www.django-rest-framework.org/api-guide/relations/#writable-nested-serializers Example I have these models. class SearchCity(models.Model): city = models.CharField(max_length=200) class SearchNeighborhood(models.Model): city = models.ForeignKey(SearchCity, on_delete=models.CASCADE)

How do I do select from a one-to-many relationship in CodeIgniter?

流过昼夜 提交于 2019-12-08 12:35:16
问题 I have a number of tables that I'm trying to access in CodeIgniter, and one of them is basically a collection of foreign keys from the other tables, most of which are only two fields: a unique id and a name. The "campaigns" table, let's call it, pulls data from other tables in the form of those tables' ids (because the names may not be unique). Now what I want to do is display the "campaigns" data in human-readable form, meaning, showing the foreign names, not the ids. I think this is called

SQLite UPDATE field in one table based on foreign key of another table

与世无争的帅哥 提交于 2019-12-08 12:32:53
问题 As in this question (SQLite field with a list of foreign keys), I'm trying to keep my real estate agents and listings in an SQLite DB with python. I did as suggested and now have tables that look like this: CREATE TABLE listings( listing_id INTEGER PRIMARY KEY AUTOINCREMENT, listing_address TEXT UNIQUE NOT NULL, acq_date DATE agent_id INTEGER, FOREIGN KEY (agent_id) REFERENCES agent (agent_id) ) CREATE TABLE agent( agent_id INTEGER PRIMARY KEY AUTOINCREMENT, agent_name TEXT NOT NULL, agent

MySQL won't let me add multiple foreign keys

自作多情 提交于 2019-12-08 11:54:31
问题 So I'm working on a project in school in which we use MySQL to make a database and complete various tasks about school subjects and exam boards. One of my questions was to: "Create and populate a third table called entries , again using query scripts. This table should contain foreign keys to allow sensible links to be made with the other two tables, together with the dates of each exam." When carrying out this task I tried this code out CREATE TABLE IF NOT EXISTS entries( subject_id INT

SQLite field with a list of foreign keys

心不动则不痛 提交于 2019-12-08 09:32:54
问题 I am building an SQLite DB to keep my real estate agents' listings. I have been able to use a foreign key to identify a listing for each agent, but I want to make a list of listings in each agent's record; moving from a one-to-one relationship between agents and listings to a one-to-many relationship. Looking here: http://www.sqlite.org/draft/foreignkeys.html , there is no mention of a field that is a 'list of foreign keys'. Is what I'm trying doable? I considered that, as a workaround, I

Mapping FK into a table in talend

十年热恋 提交于 2019-12-08 09:12:18
问题 I have 2 entities in my schema. I mapped one already and now for the second one I need to also have the PK of the first entity as a FK in the second entity when mapping using talend. They are both in the same job, but how can I use the Pk of the first entity in the mapping of the second entity? enter image description here This is what I have so far (row1 is entity1 which has an autogenerated key inside the tmap) row2 is creating csv from xml file row3 maps the csv file generated from row2,

Oracle cyclic foreign key references issues

[亡魂溺海] 提交于 2019-12-08 09:10:37
问题 I've been racking my brain trying to come up with a solution to this. For a database class, I need to implement the following: Table HUSBANDS: (Name Varchar2(10)) (Wife Varchar2(10)) Table WIVES: (Name Varchar2(10)) (Husband Varchar2(10)) and using Oracle constraints, enfore the following rules: No two husbands can have the same name No two wives can have the same name Every wife must have one and only one husband Every husband must have one and only one wife So far, I have implemented the

how to insert foreign key in a table

匆匆过客 提交于 2019-12-08 08:53:54
问题 I just want to make sure that I understand PRIMARY and FOREIGN key relation before searching for some finished answers on the internet. Let's say this: We have table CITY(ID-PK,CODE,NAME) and we have table PERSON(ID-PK,NAME,LASTNAME,CITY_ID-FK) I'm confused, if in this case user needs to enter a foreign key in the table person? If not how know which city needs to be applied to the user? If user needs to enter a foreign key why to have it then because in that way we are leaving a lot of space

ASP.Net MVC 4 Update value linked to a foreign key column

。_饼干妹妹 提交于 2019-12-08 07:52:31
问题 I'm relatively new to MVC 4 and ASP.net in general. I'm trying to create a "room" with some properties, one of which queries from a list of statuses contained in another model. I have my classes set up as follows: Room.cs public class Room { [Key] public Guid RoomId { get; set; } [Required(ErrorMessage = "A Room Name is required")] public string Name { get; set; } public string Description { get; set; } public virtual Status Status { get; set; } [DisplayName("Created On")] public DateTime?

Django get attributes from foreign key's class

倖福魔咒の 提交于 2019-12-08 07:41:04
问题 I would like to show one attribute from another class. The current class has a foreign key to class where I want to get the attribute. # models.py class Course(models.Model): name = models.CharField(max_length=100) degree = models.CharField(max_length=15) university = models.ForeignKey(University) def __unicode__(self): return self.name class Module(models.Model): code = models.CharField(max_length=10) course = models.ForeignKey(Course) def __unicode__(self): return self.code def getdegree