File and data base concepts DB design
File Concepts DATA REPRESENTATION bits and bytes EBCDIC and ASCII field or data element record file or table data base FILE ORGANIZATION sequential indexed sequential direct FILE PROCESSING batch vs immediate online vs offline
DB: a set of entities and relations In city In state Street Cities States located Registered on in Cars Houses In country Occupied Owned Has by by color Citizen of Colors Persons Countries Country of origin
DB: subsystems DB logical structures: hierachical network relational DBMS DDL OS DBM User Data Base DML Application program DB logical structures: hierachical network relational
Views, Schema and Subschemas 1 2 5 4 7 9 10 8 15 12 17 13
DB Design concepts: ... how to represent entities and relations Flat files ... P# PNAME COLOR WEIGHT PROJ# PROJNAME S# QTY PROJ# S# SNAME STATUS CITY DB tables graphical S S# SNAME STATUS CITY FIELDS: P P# PNAME COLOR WEIGHT keys and atributes primary and foreign keys J PROJ# PROJNAME CITY O S# P# PROJ# QTY relational notation S ( S#, SNAME,STATUS,CITY) P ( P# ,PNAME,COLOR,WEIGHT) J ( PROJ# ,PROJNAME,CITY) O ( S#,P#,PROJ# ,QTY)
Entities and relations RELATIONS: one-to-one one-to-many many-to-many Product a supplier can provide project product can a product can use be part of can have Supplier Project a supplier can supply a project can have
DB Design principles NORMALIZATION: 1. represent each ENTITY as a TABLE 2. select the PRIMARY KEY 3. assign entity ATTRIBUTES to FIELDS 4. represent an ONE-TO-MANY relation by a FOREIGN KEY in the MANY table. 5. represent MANY-TO MANY relations as a NEW TABLE. Use FOREIGN KEYS to identify entities involved. The combination of foreign keys is the PRIMARY KEY of the new table. Assign the common attributes to fields.
DB design example Product Project Supplier many many a supplier can provide project product can a product can use be part of can have many many Supplier Project a supplier can supply many a project many can have S (S#,SNAME,STATUS,CITY) P (P#,PNAME,COLOR,WEIGHT) J (PROJ#,PROJNAME,CITY) O (S#,P#,PROJ#,QTY)