Wednesday 28 May 2014

Find all identity columns in SQL server

select
table_schema
,table_name
, column_name
, data_type
, ordinal_position
from information_schema.columns
where columnproperty(object_id(table_name), column_name,'IsIdentity') = 1
order by 1,2,3

Sunday 25 May 2014

Quick notes about database normalization


  • 1st form:
    • No repeated data group
    • Has Primary Key
  • 2nd form:
    • 1st form already
    • remove partial dependence (no-key attribute depends on ALL key attributes)
    • add link table with primary key
  •  3rd form:
    • 2nd form already
    • remove transitive dependence (no-key attribute depends ONLY on key attributes, nothing else, that is, not depend on other no-key attribute)
    • add a new table with FK constraint.
  • reference: https://www.youtube.com/watch?v=c7DXeY3aIJw