250 likes | 366 Vues
Join our comprehensive webcast on database design, covering essential topics such as databases, entities, and the basics of Entity-Relationship Diagrams (ERDs). Discover concepts like primary keys (PK) and foreign keys (FK), and learn about the different types of database models including hierarchical, network, relational, and object-oriented. We'll delve into Data Definition Language (DDL) and Data Manipulation Language (DML) alongside practical SQL examples. Enhance your knowledge on normalization, data integrity, and how to effectively manage relationships between entities in database systems.
E N D
File and data base concepts DB design
Webcast will cover • Databases • Entities • Basic ERD • PK & FK • Basic Database Design
DBMS DB: subsystems DDL User OS DBM Data DML Base Application program DB logical structures: hierachical network relational
Views, Schema and Subschemas 1 2 5 4 7 9 10 8 15 12 17 13
Types of databases • Hierarchical • Network • Relational • Object-oriented
DBMS Has Two Parts • DML: Data Manipulation Language • DDL: Data Definition Language
Structured Query Language (SQL) Syntax SELECT col names FROM tablenames WHERE conditions
Employee name Job Title Roomlocation Extension Andazola, Genevieve Secretary, Financial Aid 1-308 2245 Secretary, Student Carter, Georgia 1-224 4716 Affairs Secretary, Placement Durbin,Martina 1-110 4235 Service Secretary II,Student Ezikian, Olivia 1-224 4714 Affairs Director,Placement Hart, Dr. John 1-110B 4234 Services Jacobs, Harry M. Director, Financial Aid 1-308 2244 Assistant Director, Jones, Madalena 1-224 4715 Student Affairs Smith, Rose Secretary, Admissions 1-104 4823 Vice-President, Student Wells, Dr.Janet 1-224 4713 Affairs York, Richard Director, Admissions 1-104 4822 Example
SQLEMPLOYEE (EMPLOYEE_NAME, JOB_TITLE, ROOM_LOCATION, EXTENSION) Ex: get the names of all employees SELECT employe_ename FROM EMPLOYEE; Ex: Get employee information that have location I-308 Select * FROM EMPLOYEE WHERE ROOM_LOCATION = ‘I-308’;
PRIMARY KEY (PK) a unique identifier guarantees that each row of a relation can be uniquely addressed
BANK ACCOUNT ( ss#, cust name, cust address) What’s the PK?
BANK ACCOUNT( ss#, cuts name, cust address) • SS# can be a PK since it can not repeat in this table What happens if we add cust_account to this table BANK ACCOUNT( ss#, cuts name, cust address, cust-account)
BANK ACCOUNT( ss#, cuts name, cust address, cust-account) • ss# can NOT be a PK if we assume a customer can have multiple accounts For customer smith Table may look like 111-11-1123 smith UB CHK112 111-11-1123 smith UB SAV123 • Note now ss# can NOT be a PK since ss# values are repeating • this violates the definition of PK, it returns two rows!!!!
BANK ACCOUNT( ss#, cuts name, cust address, cust-account) • Can cust-account can be a PK?Only if two customers can NOT share the same account, i.e., no joint account
BANK ACCOUNT( ss#, cuts name, cust address, cust-account) • PK must be a combination of TWO attributes • In this case SS# and cust-account Should be PK for this relation
FK • Relates two tables • Used to maintain INTEGRITY (cross reference) An attribute in ONE table must match values in another table where that attribute is a PK
VENDOR and PRODUCT tables VENDOR (Vend_CODE, VEND_CONTACT, VEND_ADDRESS, VEND_PHONE) PRODUCT (PROD_CODE, PROD-DESCRIPTION, PROD_PRICE, PROD_ON_HAND, VEND_CODE) Red implies PK for each table Purple key is PRODUCT table is FK to VENDOR table
Entities An object of interest • Person • Place • Event • Concept Ex: Student Order Customer
Relationship Exists between entities With entity itself Binary between TWO entities Ternary between THREE entities
Relationship among entities Assume: A team can have many players and a player can play for ONLY ONE team TEAM PLAYER TEAM------- > PLAYER
Relationship? STUDENT CLUB Can a student belong to many clubs? Yes then 1:m Can a club have many student members? Yes then 1:n M:N STUDENT <-------->CLUB
DB Design Concepts how to represent entities and relations ENROLLMENT (SID, SNAME, SADD,CID,CNAME,GRADE,SEMESTER)
Remove redundancy STUDENT (SID,SNAME,SADD) CLASS(CID,CNAME) GRADE (SID,CID,GRADE,SEMESTER)
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 KEYof the new table. Assign the common attributes to fields. DB Design principles