foreign-keys

SQL Server Foreign Key constraint benefits

心不动则不痛 提交于 2019-12-30 06:31:49
问题 We're designing a database in which I need to consider some FK(foreign key) constraints. But it is not limited to formal structuring and normalization. We go for it only if it provides any performance or scalability benefits. I've been going thru some interesting articles and googling for practical benefits. Here are some links: http://www.mssqltips.com/tip.asp?tip=1296 I wanted to know more about the benefits of FK (apart from the formal structuring and the famous cascaded delete\update). FK

SQL Server Foreign Key constraint benefits

蓝咒 提交于 2019-12-30 06:31:09
问题 We're designing a database in which I need to consider some FK(foreign key) constraints. But it is not limited to formal structuring and normalization. We go for it only if it provides any performance or scalability benefits. I've been going thru some interesting articles and googling for practical benefits. Here are some links: http://www.mssqltips.com/tip.asp?tip=1296 I wanted to know more about the benefits of FK (apart from the formal structuring and the famous cascaded delete\update). FK

Support for foreign key constraint in Rails

耗尽温柔 提交于 2019-12-30 00:40:19
问题 In Ruby on Rails, how to add foreign key constraint in migration? 回答1: AFAIK, there isn't any built-in support for that, but there are several plugins that help you with that. You can also add them manually to your migration files, just use the execute method for that, e.g. (sample from Rails API): class MakeJoinUnique < ActiveRecord::Migration def self.up execute "ALTER TABLE `pages_linked_pages` ADD UNIQUE `page_id_linked_page_id` (`page_id`,`linked_page_id`)" end def self.down execute

SQL : one foreign key references primary key in one of several tables

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 08:26:12
问题 I am working on an application that will be used as an extensible framework for other applications. One of the fundamental classes is called Node, and Nodes have Content. The SQL tables look like this: TABLE Node ( NodeId int, .... etc ) TABLE NodeContentRelationship ( NodeId int, ContentType string, ContentId int) It will be up to the developers extending the application to create their own content types. Clearly this is bad from a relationship-database point of view as it is not possible to

Foreign Key to TYPO3 Frontend User

旧巷老猫 提交于 2019-12-29 07:11:27
问题 How can I set a ForeignKey to the TYPO3 FrontendUsers in the Extension Builder? Do I have to set the param map to existing table? oder make a relation? What I want to do: I've got a Model (People) with its own fields and values. and now I want to have a new Releation between this Model and the TYPO3 FE Users PeopleNr = fe_user with uid 123 回答1: Note: As stated in other question creating relations between tables/models doesn't require adding foreign keys I'm not quite sure what do you need it

How to keep foreign key relations consistent in a “diamond-shaped” system of relationships

限于喜欢 提交于 2019-12-29 07:04:27
问题 Consider this situation: a Car is bought from a Salesperson . A Salesperson works at a Showroom (and at only one Showroom). A Showroom is affiliated to a Manufacturer , and only sells cars made by that Manufacturer. At the same time, a Car is of a particular Model , and a Model is made by a Manufacturer. Restriction R: A Car's Model's Manufacturer must be the same Manufacturer as the Car's Salesperson's Showroom's affiliated Manufacturer. The diagram shows the obvious foreign key

How to keep foreign key relations consistent in a “diamond-shaped” system of relationships

纵饮孤独 提交于 2019-12-29 07:04:20
问题 Consider this situation: a Car is bought from a Salesperson . A Salesperson works at a Showroom (and at only one Showroom). A Showroom is affiliated to a Manufacturer , and only sells cars made by that Manufacturer. At the same time, a Car is of a particular Model , and a Model is made by a Manufacturer. Restriction R: A Car's Model's Manufacturer must be the same Manufacturer as the Car's Salesperson's Showroom's affiliated Manufacturer. The diagram shows the obvious foreign key

Foreign Key naming scheme

半腔热情 提交于 2019-12-29 02:24:13
问题 I'm just getting started working with foreign keys for the first time and I'm wondering if there's a standard naming scheme to use for them? Given these tables: task (id, userid, title) note (id, taskid, userid, note); user (id, name) Where Tasks have Notes, Tasks are owned by Users, and Users author Notes. How would the three foreign keys be named in this situation? Or alternatively, does it even matter at all ? Update : This question is about foreign key names, not field names! 回答1: The

Can I use a counter in a database Many-to-Many field to reduce lookups?

偶尔善良 提交于 2019-12-29 01:59:10
问题 I am trying to figure out the fastest way to access data stored in a junction object. The example below is analagous to my problem, but with a different context, because the actual dataset I am dealing with is somewhat unintuitive in its relationships. We have 3 classes: User , Product , and Rating . User has a many-to-many relationship to Product with Rating as the junction/'through' class. The Rating object stores the answers to several questions which are integer ratings on a scale of 1-5

PostgreSQL foreign key not existing, issue of inheritance?

≡放荡痞女 提交于 2019-12-28 06:32:32
问题 I am struggling with foreign keys in my DB, possibly it has something to do with inheritance? So here's the basic setup: -- table address CREATE TABLE address ( pk_address serial NOT NULL, fk_gadmid_0 integer NOT NULL, -- this table already exists, no problem here street character varying(100), zip character varying(10), city character varying(50), public boolean, CONSTRAINT address_primarykey PRIMARY KEY (pk_address), CONSTRAINT gadmid_0_primarykey FOREIGN KEY (fk_gadmid_0) REFERENCES adm0