Course Name

advertisement
Database Design Notes
Team Organization:
Teams:
1) Divide members into teams (3 or 4 members per team)
2) Select team leader
3) Each team conceptual design: ERD, entity list, entity attributes, etc. (see below)
4) Critique: Best design (5 pts. on Midterm Exam, equiv. to half a letter grade)
5) Each team: begin logical design (ea. Table), report to team leader of best design
1)






Conceptual design (data modeling):
represents data from viewpoint of organization
Determine organization’s requirements
Business rules
Develop data models
ER diagrams (define relationships, cardinalities, etc.)
Primary goal: Getting right requirements
2)







Logical design:
Translate business requirements and convert requirements into a normalized model
Translate SAW entities into relations (tables)
Mapping (e.g., entity w/multivalued attribute maps to two relations)
Normalization techniques
Creating stable database structure for processing data
Ensure entity, data integrity: PKs, constraints, data and referential integrity p. 67
Primary goal: Getting requirements right
3)




Physical design:
Translate logical design into technical specifications
Efficiency, security, recoverability
last step in database design process
Primary goal: data processing efficiency
Database Design Steps
Conceptual Design:
Planning and Designing:
Detailed description of organization’s/project’s operations – What is needed?
Identify business rules based on
a. description of operations
b. interviews
c. reports drawn from data (if any)
3) Identify entities and relationships from business rules (organize in table – p. 128)
a. connectivity and cardinality (add cardinality column to table p. 128)
b. relationships
i. define with verbs (e.g., has, generates, contains, etc. p. 129)
ii. type:
1. strong/identifying (draw appropriately)
2. weak/non-identifying (draw appropriately)
c. type: strong, associative, weak
4) Identify transaction requirements: SELECT, INSERT, UPDATE, DELETE
5) Identify PKs, FKs, PFs (PK in one entity and FK in another), and attributes
***Create ERD, review and revise ERD (iterative, including steps below)
1)
ERD –
1)
2)
1
2) Logical Design:
Define (not create) tables, indexes, and views
Map entities to relations/tables (organize in table format):
1) Name (e.g., CUSTOMER)
2) Attribute prefix (e.g., CUS_)
Entity
1)
2)
3)
4)
5)
Attributes (organize in table format):
Attribute name (CUST_ID)
Contents (state what value it holds, example: customer identification code)
Type (simple, composite, derived (stored or unstored), multi-valued)
PK, FK, or PF
References (FK reference to PK entity)
Normalize tables to 3rd Normal Form
Create Data Dictionary (organize in table format –p. 75):
1) Table name (CUSTOMER)
2) Attribute name (CUS_ID)
3) Contents (state what value it holds, example: customer identification code)
4) Data type
5) Format
6) Domain (may or may not be same as range)
7) Sample Data (1, “John”, etc.)
8) Required (Y/N)
9) PK, FK, or both (PF)
10) References (FK reference to PK entity)
a. FK attribute constraint (Appendix D - Converting ER into Physical Design)
b. FK action (see Appendix D - Converting ER into Physical Design)
***Review and revise ERD
3) Physical Design:
Where suitable: Create database(s), tables, indexes, views, procedures, triggers
Example:
DROP TABLE IF EXISTS `agent`;
CREATE TABLE `agent`
(
`aid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`ofid` smallint(5) unsigned NOT NULL DEFAULT 0,
`afirst` varchar(10) NOT NULL DEFAULT '',
`alast` varchar(15) NOT NULL DEFAULT '',
`aphone` char(12) DEFAULT NULL,
PRIMARY KEY (`aid`),
INDEX `idx_Agent_Office` (ofid ASC),
CONSTRAINT `fk_Agent_Office`FOREIGN KEY (ofid) REFERENCES
office (ofid) ON DELETE RESTRICT ON UPDATE CASCADE
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
***Define security, users, groups, roles, backup and recovery procedures***
2
References
MySQL Reference Manual:
http://dev.mysql.com/doc/refman/5.1/en/index.html
MySQL Tables:
http://dev.mysql.com/doc/refman/5.1/en/create-table.html
MySQL Data Types:
http://dev.mysql.com/doc/refman/5.1/en/data-types.html
MySQL Foreign Keys:
http://dev.mysql.com/doc/refman/5.1/en/ansi-diff-foreign-keys.html
http://dev.mysql.com/doc/refman/5.1/en/ansi-diff-foreign-keys.html
http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
MySQL Indexes:
http://www.databasejournal.com/features/mysql/article.php/1382791/Optimizing-MySQLQueries-and-Indexes.htm
http://www.databaseguides.com/what-are-database-indexes
http://www.websitedatabases.com/database-index.html
http://www.interspire.com/content/articles/34/1/Introduction-to-Database-Indexes
MySQL Views:
http://dev.mysql.com/doc/refman/5.1/en/views.html
MySQL Procedures:
http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html
MySQL Triggers:
http://dev.mysql.com/doc/refman/5.1/en/triggers.html
http://www.databasedesign-resource.com/mysql-triggers.html
http://www.mysqltutorial.org/mysql-triggers.aspx
MySQL Optimization:
http://dev.mysql.com/doc/refman/5.1/en/optimization.html
MySQL Backup:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
MySQL Replication:
http://dev.mysql.com/doc/refman/5.1/en/replication-features-create-if-not-exists.html
3
Download