Search Results

Search found 6628 results on 266 pages for 'foreign keys'.

Page 4/266 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Fluent composite foreign key mapping

    - by Fionn
    Hi, I wonder if this is possible to map the following with fluent nhibernate: A document table and a document_revision table will be the target tables. The document_revision table should have a composite unique key consisting of the document_id and the revision number (where the document_id is also the foreign key to the document table). class Document { Guid Id; //other members omitted } class DocumentRevision { Guid document_id; //Part one of the primary key and also foreign key to Document.Id int revision; //Part two of the primary key //other members omitted }

    Read the article

  • Manage Foreign key and Drop downlist for optional field in .NET

    - by Brij
    What is the best way to handle following situation? A dropdown(for master table) is optional in a particular form. But, In database table the field is constrained with foreign key. If user don't select from dropdown then It creates problem because of foreign key. One solution is to create default option in master table and use it in case of blank selection. but in dropdown, we need to handle this to show on top. Is it perfect solution? Is there any other optimized solution for this? Thanks

    Read the article

  • T-SQL foreign key check constraint

    - by PaN1C_Showt1Me
    When you create a foreign key constraint in a table and you create the script in MS SQL Management Studio, it looks like this. ALTER TABLE T1 WITH CHECK ADD CONSTRAINT FK_T1 FOREIGN KEY(project_id) REFERENCES T2 (project_id) GO ALTER TABLE T1 CHECK CONSTRAINT FK_T1 GO What I don't understand is what purpose has the second alter with check constraint. Isn't creating the FK constraint enough? Do you have to add the check constraint to assure reference integrity ? Another question: how would it look like then when you'd write it directly in the column definition? CREATE TABLE T1 ( my_column INT NOT NULL CONSTRAINT FK_T1 REFERENCES T2(my_column) ) Isn't this enough?

    Read the article

  • linq to sql using foreign keys returning iqueryable(of myEntity]

    - by Gern Blandston
    I'm trying to use Linq to SQL to return an IQueryable(of Project) when using foreign key relationships. Using the below schema, I want to be able to pass in a UserId and get all the projects created for the company the user is associated with. DB tables: Projects Projid ProjCreator FK (UserId from UserInfo table) Companyid FK (CompanyID from Companies table) UserInfo UserID PK Companyid FK Companies CompanyId PK Description I can get the iqueryable(of project) when simply getting the ProjectCreator with this: Return (From p In db.Projects _ Where p.ProjectCreator = Me.UserId) But I'm having trouble getting the syntax to get a iqueryable(of projects) when using foreign keys. Below gives me an IQueryable(of anonymous) but I can't seem to convince it to give me an IQueryable(of project) even if I try to cast it: Dim retval = (From p In db.Projects _ Join c In db.Companies On p.CompanyId Equals c.CompanyId _ Join u In db.UserInfos On u.CompanyId Equals c.CompanyId _ Where u.Login = UserId)

    Read the article

  • mysql foreign key problem.

    - by JP19
    Hi, What is wrong with the foreign key addition here: mysql> create table notes ( id int (11) NOT NULL auto_increment PRIMARY KEY, note_type_id smallint(5) NOT NULL, data TEXT NOT NULL, created_date datetime NOT NULL, modified_date timestamp NOT NULL on update now()) Engine=InnoDB; Query OK, 0 rows affected (0.08 sec) mysql> create table notetypes ( id smallint (5) NOT NULL auto_increment PRIMARY KEY, type varchar(255) NOT NULL UNIQUE) Engine=InnoDB; Query OK, 0 rows affected (0.00 sec) mysql> alter table `notes` add constraint foreign key(`note_type_id`) references `notetypes`.`id` on update cascade on delete restrict; ERROR 1005 (HY000): Can't create table './admin/#sql-43e_b762.frm' (errno: 150) Thanks JP

    Read the article

  • PostgreSQL: How to index all foreign keys?

    - by biggusjimmus
    I am working with a large PostgreSQL database, and I are trying to tune it to get more performance. Our queries and updates seem to be doing a lot of lookups using foreign keys. What I would like is a relatively simple way to add Indexes to all of our foreign keys without having to go through every table (~140) and doing it manually. In researching this, I've come to find that there is no way to have Postgres do this for you automatically (like MySQL does), but I would be happy to hear otherwise there, too.

    Read the article

  • Multiple foreign keys from one table linking to single primary key in second table

    - by croker10
    Hi all, I have a database with three tables, a household table, an adults table and a users table. The Household table contains two foreign keys, iAdult1ID and iAdult2ID. The Users table has a iUserID primary key and the Adult table has a corresponding iUserID foreign key. One of the columns in the Users table is strUsername, an e-mail address. I am trying to write a query that will allow me to search for an e-mail address for either adult that has a relation to the household. So I have two questions, assuming that all the values are not null, how can I do this? And two, in reality, iAdult2ID can be null, is it still possible to write a query to do this? Thanks for your help. Let me know if you need any more information.

    Read the article

  • How to handle Foreign key for optional field in .NET

    - by brz dot net
    What is the best way to handle following situation? A dropdown(for master table) is optional in a particular form. But, In database table the field is constrained with foreign key. If user don't select from dropdown then It creates problem because of foreign key. One solution is to create default option in master table and use it in case of blank selection. but in dropdown, we need to handle this to show on top. Is it perfect solution? Is there any other optimized solution for this? Thanks

    Read the article

  • Cannot add or update a child row: a foreign key constraint fails

    - by myaccount
    // Getting the id of the restaurant to which we are uploading the pictures $restaurant_id = intval($_GET['restaurant-id']); if(isset($_POST['submit'])) { $tmp_files = $_FILES['rest_pics']['tmp_name']; $target_files = $_FILES['rest_pics']['name']; $tmp_target = array_combine($tmp_files, $target_files); $upload_dir = $rest_pics_path; foreach($tmp_target as $tmp_file => $target_file) { if(move_uploaded_file($tmp_file, $upload_dir."/".$target_file)) { $sql = sprintf(" INSERT INTO rest_pics (branch_id, pic_name) VALUES ('%s', '%s')" , mysql_real_escape_string($restaurant_id) , mysql_real_escape_string(basename($target_file))); $result = mysql_query($sql) or die(mysql_error()); } I get the next error: Cannot add or update a child row: a foreign key constraint fails (rest_v2.rest_pics, CONSTRAINT rest_pics_ibfk_1 FOREIGN KEY (branch_id) REFERENCES rest_branches (branch_id) ON DELETE CASCADE ON UPDATE CASCADE However, this error totally disappears and everything goes well when I put directly the restaurant id (14 for example) instead of $restaurant_id variable in the sql query. The URL am getting the id from is: http://localhost/rest_v2/public_html/admin/add-delete-pics.php?restaurant-id=2 Any help please?

    Read the article

  • SQL - Dervied Foreign Key - Possible?

    - by Chad
    I'm just curious if this is possible, specifically in SQL CE (Express) with support in .NET's Entity Framework: Table1 (primary) -nvarchar(2000) url -... Table2 (with foreign key) -nvarchar(2000) domain -... foreign key on Table2.domain references Table1.url such that Table.url contains Table2.domain e.g. Table1: http://www.google.com/blah/blah http://www.cnn.com/blah/ http://www.google.com/foo Table2: google.com cnn.com Is it possible for this to be scripted and enforced by SQL CE (let alone any relation database) and, if so, can .NET's Entity Framework automatically support this if I import my database into a model?

    Read the article

  • Error 1005 when adding a foreign key constraint on mysql table

    - by luc
    Hello, I have a problem when upgrading a django and mysql app with south. I've tried to make a sql-based upgrade with the code generated by the django sqlall command and I have a similar problem. Here is the sql code: CREATE TABLE `programmations_basissupport` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `value` numeric(6, 0) NOT NULL ) ALTER TABLE `programmations_concert` ADD `basis_support_id` integer AFTER program_status_id; ALTER TABLE `programmations_concert` ADD CONSTRAINT `basis_support_id_refs_id_1e4ed8d7` FOREIGN KEY (`basis_support_id`) REFERENCES `programmations_basissupport` (`id`); An error is raised when adding the FK constraint: ERROR 1005 (HY000): Can't create table 'apidev_mnl.#sql-106e_632b00a' (errno: 150) Does anybody have an idea? Update: DEFAULT values where missing but even if I add the default='' in the django model, the creation of foreign keys fails. Thanks for your help

    Read the article

  • Working with Foreign languages

    - by Matt
    My DB needs to hold strings containing foreign language characters such that; User enters string into form, form submitted and string added to DB, string will be displayed on page for viewing. I would like to use UTF8 as this will be able to handle all of the required languages. Currently I believe my DB is set to 'latin1' but webpages are capable of displaying correct charachters anyways. Problems arise when trying to set textareas to hold foreign charachters and when viewing DB via command-line. How can I implement this most effectively? My plan was to blitz the whole site such that:DB Charset is UTF8 and web pages charset is UTF8. Could someone give me the minimal commands on how to do this so I don't end up duplicating things (Having "UTF8" commands everywhere when I really just need one) and making things too difficult to control. Newbie Thanks

    Read the article

  • Bind "media" keys on MacBook keyboard to application menu items

    - by Austin
    Currently, I am using PandoraBoy to listen to my Pandora stations. In the preferences, it allows you to set global hotkeys to control playing, like/dislike, volume, stations, etc. What I would like to do is allow the built-in media keys on my MacBook Pro's keyboard (F7-F12: Previous, Play/Pause, Next, Mute, Volume Up, Volume Down) to control PandoraBoy like they do iTunes. Right now, I am using Command-F(7-12) to control it, but that requires me to hold down the "fn" and command keys Is there a way to bind these commands to the media keys without needing to function-shift them?

    Read the article

  • Special function keys are mixed up on my Macbook Pro

    - by seanieb
    I recently sent my Macbook Pro (late 2008 model) to get a replaced logic board and top cover. When I got it back the Special function keys are mixed up. F3 - mutes sound - it should do expose f4 - decreases volume - it should show the dashboard f5 - increases volume ....etc, ... F11 - expose - it should decrease volume f12 - dashboard - it should increase volume I have checked and made sure that System PreferencesKeyboard"use all F keys as standard function keys" is not selected. And that no accessibility options are switched on either. How do I fix this? or should I bring it back to the repair shop? Thanks

    Read the article

  • MySQL Unions/Subselects not utilizing keys from associated tables

    - by Brett
    I've noticed by doing EXPLAINs that when a MySQL union between two tables is used, mysql creates a temporary table, but the temp table does not use keys, so queries are slowed considerably. Here is an example: SELECT * FROM ( SELECT `part_number`, `part_manufacturer_clean`, `part_number_clean`, `part_heci`, `part_manufacturer`, `part_description` FROM `new_products` AS `a` UNION SELECT `part` as `part_number`, `manulower` as `part_manufacturer_clean`, `partdeluxe` as `part_number_clean`, `heci` as `part_heci`, `manu` as `part_manufacturer`, `description` as `part_description` FROM `warehouse` AS `b` ) AS `c` WHERE `part_manufacturer_clean` = 'adc' EXPLAIN yields this: id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL (NULL) (NULL) (NULL) (NULL) 17206 Using where 2 DERIVED a ALL (NULL) (NULL) (NULL) (NULL) 17743 3 UNION b ALL (NULL) (NULL) (NULL) (NULL) 5757 (NULL) UNION RESULT <union2,3> ALL (NULL) (NULL) (NULL) (NULL) (NULL) In this case, part_manufacturer_clean and manulower are keys in both tables. When I don't use the subselects and union, and just use one table, everything works fine. I'm not sure if the issue is with the union or with the subselects. Is there any way to union two tables and still use keys/indexes for performance?

    Read the article

  • ElanTech touchpad both keys simultaneously don't work

    - by Wojciech
    I have a huge problem with ElanTech touchpad. Without the ElanTech driver both the keys can be used at the same time(R+L). This is usefull in games like Mafia2 (can't play without it). When I install their driver I get the gestures, scrolling etc. but I can't use both keys at the same time. It is a common problem. Acer Aspire v3-571G Windows 7 x64 This didn't work at all: Synaptics 15.3.41.5 Is there any universal driver which will give me at least scrolling and simultaneous keys usage?

    Read the article

  • How do API Keys and Secret Keys work?

    - by viatropos
    I am just starting to think about how api keys and secret keys work. Just 2 days ago I signed up for Amazon S3 and installed the S3Fox Plugin. They asked me for both my Access Key and Secret Access Key, both of which require me to login to access. So I'm wondering, if they're asking me for my secret key, they must be storing it somewhere right? Isn't that basically the same thing as asking me for my credit card numbers or password and storing that in their own database? How are secret keys and api keys supposed to work? How secret do they need to be? Are these applications that use the secret keys storing it somehow? Thanks for the insight.

    Read the article

  • Disable some extra keys on keyboard in windows

    - by user1649054
    I have a keyboard with some types of extra keys, such as multimedia (play, pause, stop ,..), turn off, and etc. some times it's annoying with a "exit button" just right beside arrows that accidentally presses, and programs gonna close, and some other similar problems. I'm wondering is there any solution to disable, or change the functionality of these types of keyboard keys in Windows (win7)? Cheers

    Read the article

  • Proper SSH keys location for a system user ?

    - by Thibaut Barrère
    I have a system account with which I run a database (namely mongodb). By default it has no home. Now I'd like to trigger scp commands from that account, with ssh keys authentication to a remote server, to export backups. Should I just create a /home/mongodb and /home/mongodb/.ssh folders manually to store the SSH keys, like the default for regular users ? Is it still considered a system account after that ? Thanks!

    Read the article

  • Merge replication server side foreign key violation from unpublished table

    - by Reiste
    We are using SQL Server 2005 Merge Replication with SQL CE 3.5 clients. We are using partitions with filtering for the separate subscriptions, and nHibernate for the ORM mapping. There is automatic ID range management from SQL Server for the subscriptions. We have a table, Item, and a table with a foreign key to Item - ItemHistory. Both of these are replicated down, filtered according to the subscription. Item has a column called UserId, and is filtered per subscription with this filter: WHERE UserId IN (SELECT... [complicated subselect]...) ItemHistory hangs off Item in the publication filter articles. On the server, we have a table ItemHistoryExport, which has a foreign key to ItemHistory. ItemHistoryExport is not published. Entries in the Item and ItemHistory tables are never deleted, on the server or the client. However, the "ownership" of items (and hence their ItemHistories) MAY change, which causes them to be moved from one client subscription/partition to another from time to time. When we sync, we occasionally get the following error: A row delete at '48269404 - 4108383dbb11' could not be propagated to 'MyServer\MyInstance.MyDatabase'. This failure can be caused by a constraint violation. The DELETE statement conflicted with the REFERENCE constraint "FK_ItemHistoryExport_ItemHistory". The conflict occurred in database "MyDatabase", table "dbo.ItemHistoryExport", column 'ItemHistoryId'. Can anyone help us understand why this happens? There shouldn't ever be a delete happening on the server side.

    Read the article

  • Sort queryset by a generic foreign key (django)?

    - by thornomad
    I am using Django's comment framework which utilizes generic foreign keys. Question: How do I sort a given model's queryset by their comment count using the generic foreign key lookup? Reading the django docs on the subject it says one needs to calculate them not using the aggregation API: Django's database aggregation API doesn't work with a GenericRelation. [...] For now, if you need aggregates on generic relations, you'll need to calculate them without using the aggregation API. The only way I can think of, though, would be to iterate through my queryset, generate a list with content_type and object_id's for each item, then run a second queryset on the Comment model filtering by this list of content_type and object_id ... sort the objects by the count, then re-create a new queryset in this order by pulling the content_object for each comment ... This just seems wrong and I'm not even sure how to pull it off. Ideas? Someone must have done this before. I found this post online but it requires me handwriting SQL -- is that really necessary ?

    Read the article

  • List all foreign key constraints that refer to a particular column in a specific table

    - by Sid
    I would like to see a list of all the tables and columns that refer (either directly or indirectly) a specific column in the 'main' table via a foreign key constraint that has the ON DELETE=CASCADE setting missing. The tricky part is that there would be an indirect relationships buried across up to 5 levels deep. (example: ... great-grandchild- FK3 = grandchild = FK2 = child = FK1 = main table). We need to dig up the leaf tables-columns, not just the very 1st level. The 'good' part about this is that execution speed isn't of concern, it'll be run on a backup copy of the production db to fix any relational issues for the future. I did SELECT * FROM sys.foreign_keys but that gives me the name of the constraint - not the names of the child-parent tables and the columns in the relationship (the juicy bits). Plus the previous designer used short, non-descriptive/random names for the FK constraints, unlike our practice below The way we're adding constraints into SQL Server: ALTER TABLE [dbo].[UserEmailPrefs] WITH CHECK ADD CONSTRAINT [FK_UserEmailPrefs_UserMasterTable_UserId] FOREIGN KEY([UserId]) REFERENCES [dbo].[UserMasterTable] ([UserId]) ON DELETE CASCADE GO ALTER TABLE [dbo].[UserEmailPrefs] CHECK CONSTRAINT [FK_UserEmailPrefs_UserMasterTable_UserId] GO The comments in this SO question inpire this question.

    Read the article

  • [rails] do we need database level constraints

    - by shrimpy
    i have the same problem as in the following post http://stackoverflow.com/questions/1451570/ruby-on-rails-database-migration-not-creating-foreign-keys-in-mysql-tables so i am wondering, why rails do not support generate foreign key by default??? it is not necessary??? or we suppose to do it manually?

    Read the article

  • Multiple foreign keys in one table to 1 other table in mysql

    - by djerry
    Hey guys, I got 2 tables in my database: user and call. User exists of 3 fields: id, name, number and call : id, 'source', 'destination', 'referred', date. I need to monitor calls in my app. The 3 ' ' fields above are actually userid numbers. now i'm wondering, can i make those 3 field foreign key elements of the id-field in table user? Thanks in advance...

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >