Chapter 11
Chapter 11
Chapter 11-CS
Database and Data Modelling
File Based System
Data stored in discrete files, stored on computer, and can be accessed, altered or removed
by the user
manipulated
Features of a DBMS:
storage
among them
By Ms Payal Gupta
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
groups of users
Lock all records in the table being modified – one user changing a table, others can
Lock record currently being edited – as someone changes something, others can
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
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.
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:
3rd Normal Form (3NF): it is in 1NF and 2NF and all non-key elements are fully
MANY-TO-MANY functions cannot be directly normalized to 3NF, must use a 2 step process
e.g.
becomes:
By Ms Payal Gupta
o written in SQL
Creating a database:
Creating a table:
Changing a table:
ADD <field-name>:<data-type>
Example:
Queries:
Creating a query:
SELECT <field-name>
FROM <table-name>
WHERE <search-condition>
By Ms Payal Gupta
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>