Tag Info

New answers tagged

0

I was going to write a long post telling you that there are basically 3 ways to implement polymorphic associations, but someone (@Bill Karwin) has already done it better in a more compact way: http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back/32 Your original solution is the first one presented on the slides, the one you propose is the 3rd ...


2

Example 4 has the fewest scans and reads: Example 1 SQL Server parse and compile time: CPU time = 4 ms, elapsed time = 4 ms. SQL Server Execution Times: CPU time = 0 ms, elapsed time = 0 ms. example1 Id FirstName 1 2 Aaron 1 3 John 1 8 Aaron 1 9 John 1 14 Aaron 1 15 John 1 20 Aaron 1 ...


2

Yes, move it. The extra join overhead will be minimal (if the right indexes are in place!) and you will get a performance improvement for all the other queries which don't use addresses because you will get more rows per page in Customers and Offices. Down the road, any master data management (MDM) or data clean-up will be easier with the values all in one ...


2

If you go into your SSMS options table and look at the scripting options for object explorer do you see foreign keys and primary keys enabled? That's pretty much the only thing I can think of that may be holding you back.


3

Like @ypercube commented, check the CREATE TABLE page of the manual: There are three match types: MATCH FULL, MATCH PARTIAL, and MATCH SIMPLE (which is the default). MATCH FULL will not allow one column of a multicolumn foreign key to be null unless all foreign key columns are null; if they are all null, the row is not required to have a match in ...


0

Journey.CustomerIDis a foreign key to Customer.CustomerID. Journey.TrainNo is a foreign key to TrainRide.TrainNo. The relationship here is many to many. A TrainRide can have many customers. A customer could ride many TrainRides. The table Journey is used to associate the two. You can see the same customer more than once in this table such as 834 or the ...


1

The documentation says: Indices are not required for child key columns but they are almost always beneficial. Each time an application deletes a row from the parent table, it performs [some query]. If this SELECT returns any rows at all, then SQLite concludes that deleting the row from the parent table would violate the foreign key constraint and ...


1

Is it possible to have a foreign key that relates to information_schema No. information_schema contains views. You can't have a foreign key to a view. You can't set a foreign key to point at the underlying pg_catalog.pg_attribute table that defines columns, either, because foreign keys to system catalogs are not supported.



Top 50 recent answers are included