4.10: section 11: databases and software development Flashcards
define an attribute
-a piece of information which determines the properties of a field or tag in a database or a string of characters in a display.
define primary key
-an attribute that provides an unique identifier for every entity in a database table
define composite primary key
-a primary key made up of more than one attribute
define foreign key
- links tables via a shared attribute
- the attribute must be a primary key in one table
what is normalisation
5 points
- the process of coming up with the best possible design for a relational database to allow faster searching and sorting
- no data is duplicated
- data is consistent across tables
- flexible structure allowing as many entries as desired
- user is able to make complex queries
what is first normal form
- no repeating attributes or groups of attributes
- the database data is atomic (meaning no single column contains more than one value)
what is second normal form
- no repeating attributes or groups of attributes
- no partial dependencies
what is third normal form
- no repeating attributes or groups of attributes
- no partial dependencies
- no non key dependencies
- all attributes are dependent on the key
why are databases normalised
- easier to maintaining and modifying the database
- faster sorting and searching
- accidental deletion of records is prevented
how do you write a select sql command
SELECT attribute FROM table WHERE condition ORDER BY ASC/DESC
how do you write an update sql command
UPDATE table SET attribute = value WHERE = attribute = value
how do you write a delete sql command
DELETE FROM table WHERE condition
how do you write an insert sql command
INSERT INTO table (column1, column 2 , …) VALUES (vaule1, value2 , …)
how do you define a table with sql
CREATE TABLE Artworks (Title VARCHAR(225), Artist VARCHAR(255), Date YEAR, PRIMARY KEY (Title, Artist))
how do you do an inner join on a sql select statement
SELECT *
FROM table1 INNER JOIN table2
ON table1.column_name= table2.column_name;