Download presentation
Presentation is loading. Please wait.
Published byΝανα Ζάρκος Modified over 5 years ago
1
Getting to First Base: Introduction to Database Concepts
Chapter 14 Getting to First Base: Introduction to Database Concepts
2
Tables: Special Kinds Of Lists
A database (DB) stores data A relational database stores data in tables and describes the relationships among the different kinds of data Databaspecifys are like the lists in spreadsheets, but with added constraints Constraints limit the kinds of data they can contain, but expand the operations they can perform Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
3
Entities Anything that can de identified by a fixed number of its characteristics (attributes) Attributes have names and values The values are the data that's stored in the table To create a table, we specify the entity's name (table name), the names of the entity's attributes, and the kinds of values each attribute can have Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
4
Properties of Entities
Table Instances: Table is initially empty. It has a name and column headings (the attribute names) but no rows Each row will represent an entity An instance of the database table is the table with a specific set of rows Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
5
Properties Of Entities (Cont'd)
Structure: Content and Metadata We separate the structure of the information from the information itself A table's metadata includes its name, its attributes' names, the types of values each attribute can have, and the primary key, at a minimum Some properties are not metadata: order of rows and columns is unimportant Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
6
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
7
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
8
Properties Of Entities (cont'd)
Entities and Uniqueness A database table doesn't have any duplicate rows There must be at least one distinguishing characteristic to each entity Some characteristics may be the same, but not all Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
9
Properties Of Entities (cont'd)
Keys Any set of attributes for which all attributes are different is a candidate key Pick one and call it the primary key Key must distinguish all potential and actual entities, not just those that happen to be in the table at a given times If no combination of attributes qualify as a candidate key, assign a unique ID to each entity Like a student ID number issued by school Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
10
Operations on Tables Main use of database is to look up information
Users specify what they want to know, and the database finds it Five fundamental operations that can be performed on tables: Select, Project, Union, Difference, Product Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
11
Operations (cont'd) Select Operation
Takes rows from one table to create a new table Specify the table from which rows are to be taken, and the test for selection Syntax: Select Test From Table Test is applied to each rows of the table to determine if it should be included in result table Test uses attribute names, constants and relational operators If the test is true for a given row, the row is included in the result table; otherwise it is ignored Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
12
Operations (cont'd) Project Operation
Builds a new table from the columns of an existing table Specify name of exiting table (or tables) and the columns (field names) to be included in the new table Syntax: Project Field_List From Table The new table will have the number of columns specified, and the same number of rows as the original table, unless The new table eliminates a key field. If rows duplicate in the new table, duplicates will be eliminated Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
13
Operations (cont'd) Union Operation Difference Operation
Combines two tables (that have the same attributes) Syntax: Table1 + Table2 Difference Operation Remove from one table the rows also listed in a second table Table1 - Table2 Product Operation Creates a super table with all fields from both tables Puts the rows together Table1 Table2 Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
14
Join Operation Combines two tables, like the Product Operation, but doesn't necessarily produce all pairings If the two tables each have fields with a common data type, new table combines only the rows from the given tables that match on the fields Syntax: Table1 Table2 On Match Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
15
Join Operation (cont'd)
Match is a comparison test involving a field from each table If the same field in table 1 contains the same data in the row for that field Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
16
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
17
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
18
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
19
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
20
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
21
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
22
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
23
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
24
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
25
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
26
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
27
Copyright © 2006 Pearson Addison-Wesley. All rights reserved.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.