Database Notes

Embed Size (px)

DESCRIPTION

Just a few notes

Citation preview

Database Notes: Module 1Introduction to Core Database ConceptsIt allows the input, management, organization, and retreival of data quickly.Traditional databases are organized by records ()rows) and fields (columns) that are used for descriptive Tables - a collection of rows and columns that is used to organize information about a single topic. Used to query information. Each row within a table corresponds to individual records, and the columns to individual fields. A relational database:A collection of tables of datas all of which are formally described and organized according to a relational model. Each table must identify a column or group of columns - the PRIMARY KEY -to uniquely identify each row. Difference between a foreign and primary key?- So, this is kind of like a table of contents [table of tables]Database Management Systems (DBMS)- This is what MySQL is supposed to be.Through which users access data stored in a database. Performs admin tasks on the databases and objects contained within the database.Its's a collection of applications that allows the users and additional programs to capture and analyze data by providing additional functionality.An RDBMS (relational) is a software package to manage the relational aspects of .Database serverDedicated to physical or virtual storage of information.Multiple instances - a SQL Server instance is a copy of the sqlservr.exe program that runs as a Windows operating service. Often, multiple database servers are deployed. Easiest thing to do is to import a spreadsheet into a DBMS. Then we get to the entire spectrum into the server side of things. Business Intelligence, Cloud, and Big Data are on the far end of the spectrum; you'll be starting up at spreadsheet level.SQL Server Management StudioInstances - these are basically just individual projects.Instance is a field above a database- Within these databases they have automatically installed ones. There are already infrastructural databases- We are focusing on using the Adventure Works 2012 database. Generating queries is going to be your best friend - learn where that functionality is. Types of queriesproduction.productsYou will need to designate which database you're working in if you have multiple files under an instance. There is a command you can throw into the window: USE [+name]and then work through select from - + the name of the table that you're interested in. Data modeling (https://en.wikipedia.org/wiki/Data_modeling)http://www.agiledata.org/essays/dataModeling101.htmlA db is an organized collected of data, typically stored in electronic format.Microsoft SQL server and MySQL are examples of relational databases. DBMS is application used to perform administrative tasks on databases and used to interact with data stored in databases.Section 2Relational ConceptsConstraints and modeling referential techniques.- Normalization- Referentiality- Integrity of constraintsDesigning modeling Normalization is the process of organizing data in a database that includes creating tables and establishing relationships between the tables.Normalization forms1NF - Eliminate repeating groups2 NF - Eliminate redundant Data3 NF - Eliminate Columns not dependent on Key4 NF - Isolate Independent Multiple Relationships5 NF - Isolate Semantically Related multiple relationships - They're not going to do these last 2- Most databases are designed to the 3rd levelThe first normal form means the data is an entity format- Eliminate repeating groups in individual tables- Create separate table for each set of related data- Identify each set of related data with primary keyThe second ormal form ensures each attribute describes the entity - We create separate tables for sets of values that apply to Records should not depend on anything other than the primary key. Composite keys - in order to make something unique (not repeated in other tables) we might have to make a contingent categoryThird normal form checks for transitive dependencies. Eliminates fields that do not depend on the key.Values that are not part of the record's key to not belong to the table.If the contents of a group of fields apply to more than a single record, put those fields in a separate table. Boyce-Codd Normal FormFewest number of columns is the ideal.So their example is separate classes - 3 columns becomes one column with more rowsRedundant data doesn't help us to make any associations between the most important rows (keys)Multiple tables.Least amount of columns, then we describe what's going on in each columnSo in the first example, we have two columns (Student # and Advisor)- From this, we create two separate tables that describe those two columns in greater detail. Referential Integrity It's what we use to get the different tables to "talk" to each other. database concept used to ensure that the relationships between your database tables remains synchronized during data modifications. used to ensure that data is clean, may be helpful in optimizing database environment and the early detection of errors.A combination of primary and foreign key constraints can be used to enforce referential integrity of the database. In addition to a foreign key referencing a primary key constraint, a foreign key...Foreign and Primary KeyForeign key is used to make sure that we're adding a valid value. Enforces the validity of the content by checking the exactitude of the data already entered.Triggers seems like an interesting thing - this will involve some coding, but it will create an action resulting from Methods for enforcing referential integrityprimary key constraintforeign key constraintUnique constraintindicestriggersAny of these methods can be created as a composite key which is an index or constraint created using more than one column. It may be necessary to use more than one column to create a unique value for each row in a table.- Used to enforce uniqueness.Primary Key ConstraintOn one or more columns, a set of attributes used to uniquely identify each row.A table can only have one primary key, created by using a constraint. This is enforced by creating a unique index on the column.Foreign KeyColumn or combo of columns that are used to establish a link between data in two tables. The columns are used to create the primary key in one table are also used to create the foreign key constraint and can be used to reference data in the same table or in another table.Foreign key will initially reference a primary key?Lots of cross checking for the content.