7.1 Design Principles and Practice
- Database: a collection of data organized in a particular way for efficient computerized storage and retrieval
- Persistence: data in a database persists beyond the life of the program or programs that access those data
- Relational model: relational databases can be stored as a collection of two-dimensional tables
7.1.1 Database Creation
- The database must first be created and initialized
7.1.2 Connecting the Program to the Database
- mysql_connect($host, $user, $password)
- connnects the program with the database server
- mysql_select_db($database, $connected)
- mysql_error()
- mysql_close()
- mysql_query($query)
7.1.3 Tables
- Attribute: a column of a table that has a unique name and a data type
7.1.3.1 Table Naming Conventions
- "Use names that unify classes and instance variables with their corresponding database tables and column headings"
7.1.4 Normalization and Keys
- Normalization: a strategy for designing tables so that they support general-purpose querying and ensure data integrity
- Primary key: a unique identifier
7.1.5 Backup and Recovery
- modern DBMS systems can just use an "export" command
7.2 Working with a Database
Three important types of actions
- The table must first be created
- Individual rows of the table can then be retrieved, added, deleted, or changed (updated)
- The table can be removed from the database, or dropped, in which case all its data are also lost
The rest of this section is primarily example commands
7.3 Database Security and Integrity
A secure database accomplishes all of the following goals:
- It prevents unauthorized or accidental disclosure, alteration, or destruction of data.
- It prevents unauthorized or accidental access to data considered confidential to the organization or individual who owns the data.
- It ensures data integrity, so that the data stored in the database are always valid and accurate.
7.3.1 Database-Level Permissions
Four levels of access
- Server level: privileges that apply to all databases on the server
- Database level: privileges that apply to all tables in a particular database on the server
- Table level: privileges that apply to all columns of a particular table in the database
- Column level: privileges that apply to an individual column of a table in the database
7.3.2 User-Level Permissions
7.3.3 Controlling Concurrency
MySQL uses table locking to ensure database integrity when several users (sessions) are accessing the database at the same time.
7.4 Adding New Software Features: Database Impact
No comments:
Post a Comment