130 likes | 269 Views
Creating a Database in Access. Creating a database involves Logical design of tables and relationships Physical design of tables and relationships Populating tables. Logical Design of Library DB. DB consists of these tables Books (bkID, bkTitle, bkPrice) Authors (auID, auName, auPhone)
E N D
Creating a Database in Access • Creating a database involves • Logical design of tables and relationships • Physical design of tables and relationships • Populating tables
Logical Design of Library DB • DB consists of these tables • Books (bkID, bkTitle, bkPrice) • Authors (auID, auName, auPhone) • Publishers (pubID, pubName, pubPhone)
Logical Design of Library DBTable Relationships Authors auID auName auPhone BooksbkID bkTitle bkPrice pubID auID PublisherspubID pubName pubPhone
Physical Design of DB (Access) • Create a new Database (e.g., myLibrary) • Create tables • Create fields • Go to design view • Insert fields • Select field types • Determine field properties • Create more tables and their fields
Physical Design of DB (Access) • Relate tables • DesignRelationships • Connect key fields
Input Table Data • Open a DB in Access (e.g., myLibrary) • Open a table (e.g., publishers) • Enter field data
Queries • One table • Display publisher names and their phone numbers • Display book titles and their prices • Display author names and their phone numbers • Two tables • Display book titles, their prices, and their publishers • Display book titles, their prices, and author names • Three tables • Display book titles, their authors, and their publishers
Queries • Which books are $25 or less? • What is the phone number of publisher Big House? • What is the phone number of Shakespeare? • Who publishes the book Hamlet? • All books published by Big House over $10.00 • All books written by Shakespeare and their publisher
Additional Queries • List all copywritten materials used in Illiad. • List all special photographs used in Balloon. • Display the author, publisher, and ISBN of Emma, and owners of all copywritten material • What is the name of author Spencer’s wife? • How many children does author Shakespeare have?
Modifying Database • The current design allows only 1 author for each book. • How can we allow more than 1 author for one book (e.g., co-authors)? Authors auID auName auPhone BooksbkID bkTitle bkPrice pubID auID PublisherspubID pubName pubPhone 1 1 ∞ ∞
Modifying Database • Remember, every relationship between two tables must be 1-to-∞ or ∞-to-1. • Solution: Introduce an artificial linking table between Books a ∞ nd Authors. BooksAuthors bkauID bkID auID Authors auID auName auPhone PublisherspubID pubName pubPhone BooksbkID bkTitle bkPrice pubID auID 1 1 ∞ ∞
Logical Design of Library DBTable Relationships Authors auID auName auPhone BooksbkID bkTitle bkPrice pubID auID PublisherspubID pubName pubPhone
Access Exercises • Tables • Books • Authors • Publishers • BooksAuthors