DATABASE SYSTEMS CS-400 INTRODUCTION TO COURSE LAYOUT PLAN Course Outline Recommended Books Assessment Criteria Lab Work Database Basic concepts Database Administration RECOMMENDED BOOKS Text Book: The Beginning Database Design Solutions by Rod Stephens Student Guides for Oracle Database Administration. Year/Edition: 2010 Aug Title: Oracle Database 11g: Administration Workshop 1 (Volume 1 and 2) Pro SQL Server 2008 Relational Database Design and Implementation by Louis Davidson, Kevin Kline, Scott Klein, and Kurt Windisch Reference Books: Practical SQL, 2nd Ed, A Beginner's Guide to Storytelling with Data, Anthony DeBarros SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL, Walter Shields Database Design and Implementation, Edward Sciore,Wiley,2008 Concurrency Control and Recovery in Database Systems, Bernstein/Hadzilacos/Goodman, 1987, Addison-Wesley Fundamentals of Data Base Management Systems, Elmasri/Navathe, Pearson International Edition Data Base Systems, Design, Implementation and Management , Rob, Coronel, Thomson Course Technology Databases and Transaction Processing, Lewis, Bernstein, Kifer, Addison Wesley, 2001 Concepts of Data Base Management, Pratt/Adamski, Thomson Course Technology ASSESSMENT CRITERIA Quiz Assignment Semester Project Mid & Final Exams. Assessment Marks Mid Tem Exam 18 Final Exam (Theory) 30 Assignments 06 Quizzes 06 Final Exam (Practical) 20 (1 / 2) KEY CONCEPTS Terminology Details Data Raw Facts and Figures. Information Processed form of data. Attribute Refers to a database component, such as a column. Tuple A tuple is a row of a relation. Degree The number of attributes in a relation determines the degree of relation. A relation having three attributes is said to have a relation of degree 3. Cardinality Refers to the uniqueness of data values contained in a particular column (attribute) of a database table. The lower the cardinality, the more duplicated elements in a column. Table An arrangement of information or data, typically in rows and columns, or possibly in a more complex structure. Database An organized collection of structured information or data, typically stored electronically in a computer system. (2 / 2) KEY CONCEPTS Terminology Details DBMS A software package designed to store, retrieve, query and manage data. Primary Key A key in a relational database that is unique for each record Foreign Key A column or columns of data in one table that connects to the primary key data in the original table. SQL Structured Query Language is a computer language for storing, manipulating and retrieving data stored in a relational database. No-SQL Not only SQL. NoSQL databases store data in documents rather than relational tables. NoSQL databases are built from the ground up to store and process vast amounts of data at scale and support a growing number of modern businesses. Relational Model Relational Model represents how data is stored in Relational Databases. A relational database stores data in the form of relations (tables). Relational Database A relational database is a type of database that stores and provides access to data points that are related to one another. DATA DESIGN TERMINOLOGY Data model A formal way of representing the data that are used and created by a business system. Shows the people, places and things about which data is captured and the relationships among them. Logical data model shows the organization of data without indicating, how it is stored, created, or manipulated. 8 DATA DESIGN TERMINOLOGY Entity: A definable thing or concept within a system, such as a person/role (e.g. Student), object (e.g. Invoice), concept (e.g. Profile) or event (e.g. Transaction). When determining entities, think of them as nouns. Note: In ER diagram, the term "entity" is often used instead of "table", but they are the same. 9 DATA DESIGN TERMINOLOGY Entity Type Its a logical grouping of data relevant to a particular application. An entity instance is an occurrence of an entity type. It would be represented in a RDBMS as a table. An entity instance would be represented as a single row in a table 10 DATA DESIGN TERMINOLOGY Table or file: A set of related records is grouped together, which stores data about a specific entity. Tables are shown as two-dimensional structures that consist of vertical columns representing fields and horizontal rows representing records. Field: A single characteristic or fact about an entity. A field, or attribute, is the smallest piece of data that has meaning within an information system. For instance: A CNIC or company name could be examples of a field. The terms, data element and field, are used interchangeably. Attribute names are nouns Sometimes entity name is added at the beginning of the attribute name for clarity 11 DATA DESIGN TERMINOLOGY Common field: A common field is an attribute that appears in more than one entity. Common fields can be used to link entities in various types of relationships. Record: also called a tuple, is a set of related fields that describes one entity instance, or member of an entity, such as one customer, one order, or one product. A record might have one or dozens of fields, depending on what information is needed. 12 DATA DESIGN TERMINOLOGY Key Fields Key fields are used during the systems design phase to organize, access, and maintain data structures. The four types of key fields are primary keys, candidate keys, foreign keys, and secondary keys. 13 DATA DESIGN TERMINOLOGY Key Fields Primary key: A field or combination of fields that uniquely identifies a particular instance of an entity. Can’t be left blank in case of entering a record. An identifier may be ‘artificial,’ such as creating an ID number. E.g., In a student table the student number is a unique primary key because no two students can have the same student number. That key also contains no information beyond what is needed to identify the student. Sometimes, it is necessary for a primary key to consist of a combination of fields. In that case, the primary key is called a combination key, composite key, concatenated key, or multi-valued key. For example, if a student registers for three courses, his or her student number will appear in three records so its no more valid as a primary key. So in the registration file, neither the student number nor the course ID is unique, to identify a specific student in a specific course, the primary key must be a combination of student number and course ID. 14 DATA DESIGN TERMINOLOGY Attribute Names Primary Key Columns Field R e c o r d Supplier Number Supplier Name Supplier Address Supplier Tel. No. Sup Con 1463 Ahmad 115 zeriab St +962/7563025 Ali 3621 Ali & sons 12 King Hussien St 020-8… ... 2327 Bella Sonic Lake Industrial Estate +962/7999663 ... 6762 … 3 Lot’s Corner ... ... 15 DATA DESIGN TERMINOLOGY Key Fields Candidate key: Sometimes it is possible to have a choice of fields or field combinations to use as the primary key. Any field that could serve as a primary key is called a candidate key. For example, if every employee has a unique employee number, then you could use either the employee number or the CNIC as a primary key. Nonkey field: Any field that is not a primary key or a candidate key is called a nonkey field. 16 DATA DESIGN TERMINOLOGY Key Fields Foreign key: Field in one table that must match a primary key value in another table in order to establish the relationship between the two tables. Unlike a primary key, a foreign key need not be unique A foreign key must either match a primary key or else be null Secondary key: is a field or combination of fields that can be used to access or retrieve records. Secondary key values are not unique. For example, if you need to access records for only those customers in a specific ZIP code, you would use the ZIP code field as a secondary key. Secondary keys also can be used to sort or display records in a certain order. 17 DATA DESIGN TERMINOLOGY Entity Integrity Entity integrity constraints are rules for primary keys: The primary key cannot have a duplicate value The primary key cannot have a null value If the primary key is a composite key, none of the fields in the key can contain a null value 18 DATA DESIGN TERMINOLOGY Referential Integrity Validity checks can help avoid data input errors One type of validity check, called referential integrity, is a set of rules that a voids data inconsistency and quality problems In a relational database, referential integrity means that a foreign key value cannot be entered in one table unless it matches an existing primary key in another table You cannot change a primary key that has matching child table records A child table that has a foreign key for a different record Referential integrity also can prevent the deletion of a record has a primary key that matches foreign keys in anther table 19 Primary keys DATA DESIGN TERMINOLOGY Secondary key Foreign key Secondary key Candidate keys ombination imary key 20 Shahid Hussain Rathore (0333-5145779) rathore@hotmail.com THANKS Q&A SESSION