Databases Introduction - concepts Concepts of Relational Databases Domain definitions Example Catch Up • • • • • • Relation table file Attribute column field Tuple row record Domain Cardinality Candidate key primary key foreign key • Null • Entity integrity (row have a primary key) • Referential integrity () Entity Integrity • Normal forms – 1,2,3 NF – Boyce-codd – 4,5 NF 1st Normal Form • The first normal form (1NF) is all about eliminating repeating groups of data • Guaranteeing atomicity (the data is selfcontained and independent). At a high level, it works by creating a primary key • In short: primary key + no double values 2nd Normal Form • The table must be in 1NF • Each column must depend on the whole key i.e. only relevant for combined keys part of columns can not be dependent of only a part of the key • In short: 1NF + all values(attributes) are pointed out by the whole key 3rd Normal Form • The table must be in 2NF • No column can have any dependency on any other non-key column • You cannot have derived data • In short: 2NF + all values(attributes) can only be pointed out by the whole key Referential Integrity • Constraints on foreign key’s – On Delete – No Action, Null(0-*), Default, Cascade(composite / 1-*) – On Update – No Action, Null, Default, Cascade – See more: http://technet.microsoft.com/en-us/library/aa902684(v=sql.80).aspx Structured Query Language • Data Definition Language (DDL) or data description language – Define tables, relations, triggers, stored procedures, user datatype etc. • Data Manipulation Language (DML) – Request data (select) – Update data (insert, update, delete) Select (Read) • Select (columns | *) – From table (combination of tables = join) – Where only some values • • • • • select * from scouts select id,name from scouts select id,name from scouts where 1<id AND id<10 select * from scouts where 1<id AND id<10 select * from scouts where id between 1 AND 10
© Copyright 2025 Paperzz