Primary and Candidate Keys in SQL Basic SQL Query from From-List WHERE Qualification • Possibly Many Candidate Keys (Specified Using

Total Page:16

File Type:pdf, Size:1020Kb

Primary and Candidate Keys in SQL Basic SQL Query from From-List WHERE Qualification • Possibly Many Candidate Keys (Specified Using The SQL Query Language • Structured Query Language • Developed by IBM (system R) in the 1970s • Need for a standard since it is used by many vendors COS 597D: – ANSI (American Naonal Standards Instute) Principles of – ISO (Internaonal Organizaon for Standardizaon) Database and Informaon Systems • Standards: – SQL‐86 SQL: – SQL‐92 (major revision) – SQL‐99 (major extensions) Overview and highlights – SQL 2003 (XML ↔ SQL) – SQL 2008 – SQL 2011 – connue enhancements Based on slides for Database Management Systems by R. Ramakrishnan and J. Gehrke Creang Relaons in SQL Referenal Integrity in SQL • CREATE TABLE Movie ( Observe: name CHAR(30), •type producer CHAR(30), • SQL‐92 on support all 4 opons on deletes and updates. (domain) rel_date CHAR(8), – Default is NO ACTION (delete/update is rejected) of each rang CHAR, attribute PRIMARY KEY (name, producer, rel_date) ) – CASCADE (also delete all tuples that refer to deleted tuple) specified • CREATE TABLE Employee ( – SET NULL / SET DEFAULT (sets foreign key value of SS# CHAR(9), referencing tuple) •type name CHAR(30), enforced addr CHAR(50), CREATE TABLE Acct by DBMS startYr INT, (bname CHAR(20) DEFAULT ‘main’, whenever PRIMARY KEY (SS#)) acctn CHAR(20), tuples are • CREATE TABLE Assignment ( bal REAL, added or posion CHAR(20), PRIMARY KEY ( acctn), modified. SS# CHAR(9), FOREIGN KEY (bname) REFERENCES Branch manager SS# CHAR(9), ON DELETE SET DEFAULT ) PRIMARY KEY (posion), FOREIGN KEY(SS# REFERENCES Employee), BUT individual implementations may NOT support FOREIGN KEY (managerSS# REFERENCES Employee) ) SELECT [DISTINCT] select-list Primary and Candidate Keys in SQL Basic SQL Query FROM from-list WHERE qualification • Possibly many candidate keys (specified using UNIQUE), one of which is chosen as the primary key. • from‐list A list of relaon names (possibly with a range‐ variable aer each name). • at most one book with a CREATE TABLE Book • select‐list A list of aributes of relaons in from‐list given title and edition – date, (isbn CHAR(10) • qualificaon Comparisons (Ar op const or Ar1 op publisher and isbn are title CHAR(100), Ar2, where op is one of <, >,=, ≤, ≥, ≠ ) combined determined ed INTEGER, using AND, OR and NOT. • Used carelessly, can prevent pub CHAR(30), • DISTINCT is an oponal keyword indicang that the the storage of database date INTEGER, answer should not contain duplicates. Default is that instances that arise in PRIMARY KEY (isbn), duplicates are not eliminated! practice! Title and ed suffice? UNIQUE (title, ed )) UNIQUE (title, ed, pub)? Conceptual Evaluaon Strategy Example Instances • Semancs of an SQL query defined in terms instance of bname bcity assets of the following conceptual evaluaon Branch strategy: pu Pton 10 • We will use these nyu nyc 20 – Compute the cross‐product of from‐list. instances of the Acct – time sq nyc 30 Discard resulng tuples if they fail qualificaons. and Branch relaons – Delete aributes that are not in select‐list. in our examples. – If DISTINCT is specified, eliminate duplicate rows. bname acctn bal • This strategy is probably the least efficient instance of way to compute a query! An opmizer will Acct pu 33 356 find more efficient strategies to compute the nyu 45 500 same answers. Example of Conceptual Evaluaon Expressions and Strings SELECT acctn SELECT name, age=2011-yrofbirth FROM Branch, Acct FROM Alumni WHERE Branch.bname=Acct.bname AND assets<20 WHERE dept LIKE ‘C%S’ bname bcity assets bname acctn bal • Illustrates use of arithmec expressions and string pu Pton 10 pu 33 356 paern matching: Find pairs (Alumnus(a) name pu Pton 10 nyu 45 500 and age defined by year of birth) for alums whose nyu nyc 20 pu 33 356 dept. begins with “C” and ends with “S”. nyu nyc 20 nyu 45 500 • LIKE is used for string matching. `_’ stands for any time sq nyc 30 pu 33 356 one character and `%’ stands for 0 or more time sq nyc 30 nyu 45 500 arbitrary characters. CREATE TABLE Acct Range Variables (bname CHAR(20), acctn CHAR(20), bal REAL, • Refer to tuples from a relaon PRIMARY KEY ( acctn), FOREIGN KEY (bname REFERENCES Branch ) • Really needed only if the same relaon FROM CREATE TABLE Branch CREATE TABLE Cust appears twice in the clause. : (bname CHAR(20), (name CHAR(20), bcity CHAR(30), street CHAR(30), SELECT acctn assets REAL, city CHAR(30), FROM Branch, Acct PRIMARY KEY (bname) ) PRIMARY KEY (name) ) WHERE Branch.bname=Acct.bname AND assets<20 CREATE TABLE Owner OR OR (name CHAR(20), SELECT R.acctn SELECT R.acctn acctn CHAR(20), FOREIGN KEY (name REFERENCES Cust ) FROM Branch S, Acct R FROM Branch as S, Acct as R FOREIGN KEY (acctn REFERENCES Acct ) ) WHERE S.bname=R.bname WHERE S.bname=R.bname AND assets<20 AND assets<20 Nested Queries Nested Queries Find names of all branches with accts of cust. who live in Rome Result = names of all branches with accts of cust. who live in Rome: SELECT A.bname SELECT A.bname FROM Acct A FROM Acct A WHERE A.acctn IN (SELECT D.acctn WHERE A.acctn IN (SELECT D.acctn FROM Owner D, Cust C FROM Owner D, Cust C WHERE D.name = C.name AND C.city=‘Rome’) WHERE D.name = C.name AND C.city=‘Rome’) A very powerful feature of SQL: a WHERE clause can itself contain an Princeton branch with two accts – SQL query! (Actually, so can FROM and HAVING clauses.) acct A has two owners, neither living in Rome What get if use NOT IN? acct B has one owner living in Rome and one not living in Rome To understand semancs of nested queries, think of a nested loops Is Princeton branch in Result? evaluaon: For each Acct tuple, check the qualificaon by compung the subquery. Is Princeton branch in (SELECT bname FROM Acct) - Result ? Is Princeton branch in result of replacing IN with NOT IN above? Nested Queries with Correlaon More on Set‐Comparison Operators Find acct no.s whose owners own at least one acct with a balance over 1000 SELECT D.acctn • We’ve already seen IN, EXISTS and UNIQUE. Can also FROM Owner D use NOT IN, NOT EXISTS and NOT UNIQUE. WHERE EXISTS (SELECT * • ANY ALL from , , , , , FROM Owner E, Acct R Also available: op , op , op > < = ≥ ≤ ≠ WHERE R.bal>1000 AND R.acctn=E.acctn • Find names of branches with assets at least as large as AND E.name=D.name) the assets of some NYC branch: SELECT B.bname • EXISTS set comparison operator, like IN, tests not empty set FROM Branch B • UNIQUE set operator checks for duplicate tuples WHERE B.assets ≥ ANY (SELECT Q.assets – If UNIQUE used, and * replaced by E.name, finds acct no.s whose FROM Branch Q owners own no more than one acct with a balance over 1000. Includes NYC branches? WHERE Q.bcity=’NYC’) • Why, in general, subquery must be re‐computed for each Branch tuple. note: key word SOME is interchangable with ANY - 15 ANY easily confused with ALL Division in SQL Division in SQL – simple template Schemas Find tournament winners who have won all tournaments. • WholeRelation: (r1, r2, …, rm, q1, q2, …qn) • DivisorRelation: (q1, q2, …qn) SELECT R.wname CREATE TABLE • WholeRelation ÷ DivisorRelation: (r1, r2, …, rm) FROM Winners R Winners WHERE NOT EXISTS (wname CHAR((30), SELECT R.r1, R.r2, …, R.rm ((SELECT S.tourn tourn CHAR(30), FROM WholeRelation R WHERE NOT EXISTS FROM Winners S) year INTEGER) ( (SELECT * EXCEPT FROM DivisorRelation Q (SELECT T.tourn ) FROM Winners T EXCEPT q , T.q , …T.q WHERE T.wname=R.wname)) (SELECT T. 1 2 n FROM WholeRelation T WHERE R.r1= T.r1 ∧ R.r2 = T.r2 ∧ … ∧ R.rm = T.rm ) ) COUNT (*) Aggregate Operators COUNT ( [DISTINCT] A) Division in SQL – general template SUM ( [DISTINCT] A) AVG ( [DISTINCT] A) Significant extension of MAX (A) SELECT MIN (A) FROM relaonal algebra. WHERE NOT EXISTS single column ((SELECT FROM Example: Find name and city of the poorest branch WHERE ) EXCEPT The first query is illegal! SELECT S.bname, MIN (S.assets) (SELECT FROM Branch S FROM Is it poorest branch or WHERE ) poorest branches? SELECT S.bname, S.assets FROM Branch S WHERE S.assets = can do projections and other predicates within nested selects (SELECT MIN (T.assets) FROM Branch T) GROUP BY and HAVING Queries With GROUP BY and HAVING SELECT [DISTINCT] select-list • Somemes, we want to apply aggregate FROM from-list operators to each of several groups of tuples. WHERE qualification GROUP BY grouping-list Find the maximum assets of all branches in a city HAVING group-qualification for • The select‐list contains (i) aribute names (ii) terms each city containing at least one branch. with aggregate operaons (e.g., MIN (S.age)). SELECT B.bcity, MAX(B.assets) – The aribute list (i) must be a subset of grouping‐list. FROM Branch B Intuively, each answer tuple corresponds to a group, GROUP BY B.bcity and these aributes must have a single value per group. (A group is a set of tuples that have the same value for • for each city ‐ one name ‐ aggregate assets all aributes in grouping‐list.) 22 Conceptual Evaluaon What aributes are unnecessary? • Compute cross‐product of from‐list • Discard tuples that fail qualificaon (WHERE) ↓ • Delete `unnecessary’ aributes What aributes are necessary: • Paron remaining tuples into groups by the value of aributes in grouping‐list. • Apply group‐qualificaon to eliminate some groups. Exactly those menoned in Expressions in group‐qualificaon must have a single value per group! (HAVING) SELECT, GROUP BY or HAVING clauses – In effect, an aribute in group‐qualificaon that is not an argument of an aggregate op also appears in grouping‐list. (SQL does not exploit primary key semancs here!) • Generate one answer tuple per qualifying group.
Recommended publications
  • Referential Integrity in Sqlite
    CS 564: Database Management Systems University of Wisconsin - Madison, Fall 2017 Referential Integrity in SQLite Declaring Referential Integrity (Foreign Key) Constraints Foreign key constraints are used to check referential integrity between tables in a database. Consider, for example, the following two tables: create table Residence ( nameVARCHARPRIMARY KEY, capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR ); We can enforce the constraint that a Student’s residence actually exists by making Student.residence a foreign key that refers to Residence.name. SQLite lets you specify this relationship in several different ways: create table Residence ( nameVARCHARPRIMARY KEY, capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR, FOREIGNKEY(residence) REFERENCES Residence(name) ); or create table Residence ( nameVARCHARPRIMARY KEY, capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR REFERENCES Residence(name) ); or create table Residence ( nameVARCHARPRIMARY KEY, 1 capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR REFERENCES Residence-- Implicitly references the primary key of the Residence table. ); All three forms are valid syntax for specifying the same constraint. Constraint Enforcement There are a number of important things about how referential integrity and foreign keys are handled in SQLite: • The attribute(s) referenced by a foreign key constraint (i.e. Residence.name in the example above) must be declared UNIQUE or as the PRIMARY KEY within their table, but this requirement is checked at run-time, not when constraints are declared. For example, if Residence.name had not been declared as the PRIMARY KEY of its table (or as UNIQUE), the FOREIGN KEY declarations above would still be permitted, but inserting into the Student table would always yield an error.
    [Show full text]
  • The Unconstrained Primary Key
    IBM Systems Lab Services and Training The Unconstrained Primary Key Dan Cruikshank www.ibm.com/systems/services/labservices © 2009 IBM Corporation In this presentation I build upon the concepts that were presented in my article “The Keys to the Kingdom”. I will discuss how primary and unique keys can be utilized for something other than just RI. In essence, it is about laying the foundation for data centric programming. I hope to convey that by establishing some basic rules the database developer can obtain reasonable performance. The title is an oxymoron, in essence a Primary Key is a constraint, but it is a constraint that gives the database developer more freedom to utilize an extremely powerful relational database management system, what we call DB2 for i. 1 IBM Systems Lab Services and Training Agenda Keys to the Kingdom Exploiting the Primary Key Pagination with ROW_NUMBER Column Ordering Summary 2 www.ibm.com/systems/services/labservices © 2009 IBM Corporation I will review the concepts I introduced in the article “The Keys to the Kingdom” published in the Centerfield. I think this was the inspiration for the picture. I offered a picture of me sitting on the throne, but that was rejected. I will follow this with a discussion on using the primary key as a means for creating peer or subset tables for the purpose of including or excluding rows in a result set. The ROW_NUMBER function is part of the OLAP support functions introduced in 5.4. Here I provide some examples of using ROW_NUMBER with the BETWEEN predicate in order paginate a result set.
    [Show full text]
  • Keys Are, As Their Name Suggests, a Key Part of a Relational Database
    The key is defined as the column or attribute of the database table. For example if a table has id, name and address as the column names then each one is known as the key for that table. We can also say that the table has 3 keys as id, name and address. The keys are also used to identify each record in the database table . Primary Key:- • Every database table should have one or more columns designated as the primary key . The value this key holds should be unique for each record in the database. For example, assume we have a table called Employees (SSN- social security No) that contains personnel information for every employee in our firm. We’ need to select an appropriate primary key that would uniquely identify each employee. Primary Key • The primary key must contain unique values, must never be null and uniquely identify each record in the table. • As an example, a student id might be a primary key in a student table, a department code in a table of all departments in an organisation. Unique Key • The UNIQUE constraint uniquely identifies each record in a database table. • Allows Null value. But only one Null value. • A table can have more than one UNIQUE Key Column[s] • A table can have multiple unique keys Differences between Primary Key and Unique Key: • Primary Key 1. A primary key cannot allow null (a primary key cannot be defined on columns that allow nulls). 2. Each table can have only one primary key. • Unique Key 1. A unique key can allow null (a unique key can be defined on columns that allow nulls.) 2.
    [Show full text]
  • CANDIDATE KEYS a Candidate Key of a Relation Schema R Is a Subset X
    CANDIDATEKEYS A candidate key of a relation schema R is a subset X of the attributes of R with the following twoproperties: 1. Every attribute is functionally dependent on X, i.e., X + =all attributes of R (also denoted as X + =R). 2. No proper subset of X has the property (1), i.e., X is minimal with respect to the property (1). A sub-key of R: asubset of a candidate key; a super-key:aset of attributes containing a candidate key. We also use the abbreviation CK to denote "candidate key". Let R(ABCDE) be a relation schema and consider the fol- lowing functional dependencies F = {AB → E, AD → B, B → C, C → D}. Since (AC)+ =ABCDE, A+ =A,and C+ =CD, we knowthat ACisacandidate key,both A and C are sub-keys, and ABC is a super-key.The only other candidate keysare AB and AD. Note that since nothing determines A, A is in every can- didate key. -2- Computing All Candidate Keys of a Relation R. Givenarelation schema R(A1, A2,..., An)and a set of functional dependencies F which hold true on R, howcan we compute all candidate keysofR? Since each candidate key must be a minimal subset Z of {A1,..., + An}such that Z =R,wehav e the following straightforward (and brute-force) algorithm: (1) Construct alist L consisting of all non-empty subsets of {A1, n − ..., An}(there are 2 1ofthem). These subsets are arranged in L in ascending order of the size of the subset: 〈 〉 ≤ We get L = Z1, Z2,..., Z2n−1 ,such that |Zi| |Zi+1|.
    [Show full text]
  • Pizza Parlor Point-Of-Sales System CMPS 342 Database
    1 Pizza Parlor Point-Of-Sales System CMPS 342 Database Systems Chris Perry Ruben Castaneda 2 Table of Contents PHASE 1 1 Pizza Parlor: Point-Of-Sales Database........................................................................3 1.1 Description of Business......................................................................................3 1.2 Conceptual Database.........................................................................................4 2 Conceptual Database Design........................................................................................5 2.1 Entities................................................................................................................5 2.2 Relationships....................................................................................................13 2.3 Related Entities................................................................................................16 PHASE 2 3 ER-Model vs Relational Model..................................................................................17 3.1 Description.......................................................................................................17 3.2 Comparison......................................................................................................17 3.3 Conversion from E-R model to relational model.............................................17 3.4 Constraints........................................................................................................19 4 Relational Model..........................................................................................................19
    [Show full text]
  • Data Definition Language
    1 Structured Query Language SQL, or Structured Query Language is the most popular declarative language used to work with Relational Databases. Originally developed at IBM, it has been subsequently standard- ized by various standards bodies (ANSI, ISO), and extended by various corporations adding their own features (T-SQL, PL/SQL, etc.). There are two primary parts to SQL: The DDL and DML (& DCL). 2 DDL - Data Definition Language DDL is a standard subset of SQL that is used to define tables (database structure), and other metadata related things. The few basic commands include: CREATE DATABASE, CREATE TABLE, DROP TABLE, and ALTER TABLE. There are many other statements, but those are the ones most commonly used. 2.1 CREATE DATABASE Many database servers allow for the presence of many databases1. In order to create a database, a relatively standard command ‘CREATE DATABASE’ is used. The general format of the command is: CREATE DATABASE <database-name> ; The name can be pretty much anything; usually it shouldn’t have spaces (or those spaces have to be properly escaped). Some databases allow hyphens, and/or underscores in the name. The name is usually limited in size (some databases limit the name to 8 characters, others to 32—in other words, it depends on what database you use). 2.2 DROP DATABASE Just like there is a ‘create database’ there is also a ‘drop database’, which simply removes the database. Note that it doesn’t ask you for confirmation, and once you remove a database, it is gone forever2. DROP DATABASE <database-name> ; 2.3 CREATE TABLE Probably the most common DDL statement is ‘CREATE TABLE’.
    [Show full text]
  • There Are Only Four Types of Relational Keys Candidate Key As Stated
    There are only four types of relational keys Candidate Key As stated above, a candidate key is any set of one or more columns whose combined values are unique among all occurrences (i.e., tuples or rows). Since a null value is not guaranteed to be unique, no component of a candidate key is allowed to be null. There can be any number of candidate keys in a table . Relational pundits are not in agreement whether zero candidate keys is acceptable, since that would contradict the (debatable) requirement that there must be a primary key. Primary Key The primary key of any table is any candidate key of that table which the database designer arbitrarily designates as "primary". The primary key may be selected for convenience, comprehension, performance, or any other reasons. It is entirely proper (albeit often inconvenient) to change the selection of primary key to another candidate key. As we will see below, there is no property of a primary key which is not shared by all other candidate keys in of the table except this arbitrary designation. Unfortunately E-R methodologies and RDBMS products have come to rely on the primary key almost to the exclusion of the concept of candidate keys, which are rarely supported by software. Alternate Key The alternate key s of any table are simply those candidate keys which are not currently selected as the primary key. According to { Date95 } (page 115), "... exactly one of those candidate keys [is] chosen as the primary key [and] the remainder, if any, are then called alternate keys ." An alternate key is a function of all candidate keys minus the primary key.
    [Show full text]
  • All Keys in Dbms with Example
    All Keys In Dbms With Example Leigh usually fudging whithersoever or concertina ineffably when diachronic Dickey unbuilds eventually and catachrestically. Nocturnal Chane toast deafly or syllabify presumptively when Dirk is gratulatory. Muriatic and strawy Pavel feds almost algebraically, though Rolfe evolve his almahs hobnails. We would make the keys in all dbms example of attributes Is known s control key contains a database choosing a set to retrieve the same plant as with all in dbms keys in below. Keys with all you can be in all dbms keys with example to? This example to all the ad links and in all dbms keys with example: the minimum number also update operation that each tuple. Used for each employee, let us in the. Nulls in your experience platforms are two same first columns as primary key are required for this set to table roll_no, as demonstrated here. It would work as the keys with the foreign. What is referred table then the curve with all keys in dbms example, you would be a list? Ssis tutorial of your dbms keys by the tables suggests that is not simple words, driving license number field cannot be ignored during your preferred and in all dbms keys with example. Solution for me with databases and with all keys in example, various levels table. You with all keys in dbms example, andere brauche ich für statistiken zu verfolgen. The following example: roll number of the keys and design stage, and with all candidate key in all dbms keys with example might be in.
    [Show full text]
  • 3 Data Definition Language (DDL)
    Database Foundations 6-3 Data Definition Language (DDL) Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Roadmap You are here Data Transaction Introduction to Structured Data Definition Manipulation Control Oracle Query Language Language Language (TCL) Application Language (DDL) (DML) Express (SQL) Restricting Sorting Data Joining Tables Retrieving Data Using Using ORDER Using JOIN Data Using WHERE BY SELECT DFo 6-3 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3 Data Definition Language (DDL) Objectives This lesson covers the following objectives: • Identify the steps needed to create database tables • Describe the purpose of the data definition language (DDL) • List the DDL operations needed to build and maintain a database's tables DFo 6-3 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4 Data Definition Language (DDL) Database Objects Object Description Table Is the basic unit of storage; consists of rows View Logically represents subsets of data from one or more tables Sequence Generates numeric values Index Improves the performance of some queries Synonym Gives an alternative name to an object DFo 6-3 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5 Data Definition Language (DDL) Naming Rules for Tables and Columns Table names and column names must: • Begin with a letter • Be 1–30 characters long • Contain only A–Z, a–z, 0–9, _, $, and # • Not duplicate the name of another object owned by the same user • Not be an Oracle server–reserved word DFo 6-3 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6 Data Definition Language (DDL) CREATE TABLE Statement • To issue a CREATE TABLE statement, you must have: – The CREATE TABLE privilege – A storage area CREATE TABLE [schema.]table (column datatype [DEFAULT expr][, ...]); • Specify in the statement: – Table name – Column name, column data type, column size – Integrity constraints (optional) – Default values (optional) DFo 6-3 Copyright © 2015, Oracle and/or its affiliates.
    [Show full text]
  • CSC 443 – Database Management Systems Data and Its Structure
    CSC 443 – Database Management Systems Lecture 3 –The Relational Data Model Data and Its Structure • Data is actually stored as bits, but it is difficult to work with data at this level. • It is convenient to view data at different levels of abstraction . • Schema : Description of data at some abstraction level. Each level has its own schema. • We will be concerned with three schemas: physical , conceptual , and external . 1 Physical Data Level • Physical schema describes details of how data is stored: tracks, cylinders, indices etc. • Early applications worked at this level – explicitly dealt with details. • Problem: Routines were hard-coded to deal with physical representation. – Changes to data structure difficult to make. – Application code becomes complex since it must deal with details. – Rapid implementation of new features impossible. Conceptual Data Level • Hides details. – In the relational model, the conceptual schema presents data as a set of tables. • DBMS maps from conceptual to physical schema automatically. • Physical schema can be changed without changing application: – DBMS would change mapping from conceptual to physical transparently – This property is referred to as physical data independence 2 Conceptual Data Level (con’t) External Data Level • In the relational model, the external schema also presents data as a set of relations. • An external schema specifies a view of the data in terms of the conceptual level. It is tailored to the needs of a particular category of users. – Portions of stored data should not be seen by some users. • Students should not see their files in full. • Faculty should not see billing data. – Information that can be derived from stored data might be viewed as if it were stored.
    [Show full text]
  • Chapter 9 – Designing the Database
    Systems Analysis and Design in a Changing World, seventh edition 9-1 Chapter 9 – Designing the Database Table of Contents Chapter Overview Learning Objectives Notes on Opening Case and EOC Cases Instructor's Notes (for each section) ◦ Key Terms ◦ Lecture notes ◦ Quick quizzes Classroom Activities Troubleshooting Tips Discussion Questions Chapter Overview Database management systems provide designers, programmers, and end users with sophisticated capabilities to store, retrieve, and manage data. Sharing and managing the vast amounts of data needed by a modern organization would not be possible without a database management system. In Chapter 4, students learned to construct conceptual data models and to develop entity-relationship diagrams (ERDs) for traditional analysis and domain model class diagrams for object-oriented (OO) analysis. To implement an information system, developers must transform a conceptual data model into a more detailed database model and implement that model in a database management system. In the first sections of this chapter students learn about relational database management systems, and how to convert a data model into a relational database schema. The database sections conclude with a discussion of database architectural issues such as single server databases versus distributed databases which are deployed across multiple servers and multiple sites. Many system interfaces are electronic transmissions or paper outputs to external agents. Therefore, system developers need to design and implement integrity controls and security controls to protect the system and its data. This chapter discusses techniques to provide the integrity controls to reduce errors, fraud, and misuse of system components. The last section of the chapter discusses security controls and explains the basic concepts of data protection, digital certificates, and secure transactions.
    [Show full text]
  • DBMS Keys Mahmoud El-Haj 13/01/2020 The
    DBMS Keys Mahmoud El-Haj 13/01/2020 The following is to help you understand the DBMS Keys mentioned in the 2nd lecture (2. Relational Model) Why do we need keys: • Keys are the essential elements of any relational database. • Keys are used to identify tuples in a relation R. • Keys are also used to establish the relationship among the tables in a schema. Type of keys discussed below: Superkey, Candidate Key, Primary Key (for Foreign Key please refer to the lecture slides (2. Relational Model). • Superkey (SK) of a relation R: o Is a set of attributes SK of R with the following condition: . No two tuples in any valid relation state r(R) will have the same value for SK • That is, for any distinct tuples t1 and t2 in r(R), t1[SK] ≠ t2[SK] o Every relation has at least one default superkey: the set of all its attributes o Basically superkey is nothing but a key. It is a super set of keys where all possible keys are included (see example below). o An attribute or a set of attributes that can be used to identify a tuple (row) of data in a Relation (table) is a Superkey. • Candidate Key of R (all superkeys that can be candidate keys): o A "minimal" superkey o That is, a (candidate) key is a superkey K such that removal of any attribute from K results in a set of attributes that IS NOT a superkey (does not possess the superkey uniqueness property) (see example below). o A Candidate Key is a Superkey but not necessarily vice versa o Candidate Key: Are keys which can be a primary key.
    [Show full text]