Chapter 7database and Data Modelling
Chapter 7database and Data Modelling
Data stored in discrete files, stored on computer, and can be accessed, altered or removed by
the user
DBMS: Software programs that allow databases to be defined, constructed and manipulated
Features of a DBMS:
Data management: data stored in relational databases - tables stored in secondary storage
Data modeling: analysis of data objects used in database, identifying relationships among them
Logical schema: overall view of entire database, includes: entities, attributes and relationships
Data integrity: entire block copied to user’s area when being changed, saved back when done
Data security: handles password allocation and verification, backups database automatically,
controls what certain user’s view by access rights of individuals or groups of users
Lock all records in the table being modified – one user changing a table, others can only read
table
Lock record currently being edited – as someone changes something, others can only read
record
User specifies no locks – software warns user of simultaneous change, resolve manually
Deadlock: 2 locks at the same time, DBMS must recognize, 1 user must abort task
Tools in a DBMS:
Developer interface: allows creating and manipulating database in SQL rather than graphically
Query processor: handles high-level queries. It parses, validates, optimizes, and compiles or
Table: contains a group of related entities in rows and columns called an entity set
Primary key: attribute or combination of them that uniquely define each tuple in relation
Indexing: creating a secondary key on an attribute to provide fast access when searching on
that attribute; indexing data must be updated when table data changes
Normalization
1st Normal Form (1NF): contains no repeating attribute or groups of attributes. Intersection of
2nd Normal Form (2NF): it is in 1NF and every non-primary key attribute is fully dependent on
the primary; all the incomplete dependencies have been removed. Example:
6
3rd Normal Form (3NF): it is in 1NF and 2NF and all non-key elements are fully dependent on
MANY-TO-MANY functions cannot be directly normalized to 3NF, must use a 2 step process e.g.
becomes:
7
written in SQL
Creating a database:
Creating a table:
Changing a table:
ADD <field-name><data-type>
Example:
Query and maintenance of data done using this language – written in SQL
Queries:
Creating a query:
SELECT <field-name>
FROM <table-name>
WHERE <search-condition>
SQL Operators:
= Equals to
ORDER BY <field-name>
GROUP BY <field-name>
INNER JOIN
Data Maintenance:
Deleting a record:
WHERE <condition>
UPDATE <table-name>
WHERE <condition>