(Con T) Externa

Total Page:16

File Type:pdf, Size:1020Kb

(Con T) Externa Data and Its Structure Data is actually stored as bits, but it is difficult to The Relational Data Model work with data at this level. It is convenient to view data at different levels of abstraction. Chapter 3 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 2 Physical Data Level Conceptual Data Level Physical schema describes details of how data is Hides details. stored: tracks, cylinders, indices etc. In the relational model, the conceptual schema presents Early applications worked at this level data as a set of tables. explicitly dealt with details. DBMS maps from conceptual to physical schema automatically. Problem: Routines were hard-coded to deal with Physical schema can be changed without changing physical representation. application: Changes to data structure difficult to make. DBMS would change mapping from conceptual to Application code becomes complex since it must deal physical transparently with details. This property is referred to as physical data independence Rapid implementation of new features impossible. 3 4 External Data Level Conceptual Data Level (con t) In the relational model, the external schema also presents data as a set of relations. Conceptual view An external schema specifies a view of the data of data Application 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. Physical view of data Faculty should not see billing data. DBMS Information that can be derived from stored data might be viewed as if it were stored. GPA not stored, but calculated when needed. 5 6 1 External Data Level (con t) Levels of Abstraction Application is written in terms of an external schema. billing A view is computed when accessed (not stored). payroll records Different external schemas can be provided to different View 1 View 2 View 3 External categories of users. schemas Translation from external to conceptual done automatically by DBMS at run time. Conceptual schema Conceptual schema can be changed without changing application: Physical schema Mapping from external to conceptual must be changed. Referred to as conceptual data independence. 7 8 Data Model Schema: description of data at some level Relational Model (e.g., tables, attributes, constraints, domains) A particular way of structuring data (using Model: tools and language for describing: relations) Conceptual and external schema Simple Data definition language (DDL) Mathematically based Integrity constraints, domains (DDL) Expressions ( queries) can be analyzed by DBMS Operations on data Queries are transformed to equivalent expressions Data manipulation language (DML) automatically (query optimization) Directives that influence the physical schema Optimizers have limits (=> programmer needs to know (affects performance, not semantics) how queries are evaluated and optimized) Storage definition language (SDL) 9 10 Relation Instance Relation Instance (Example) Relation is a set of tuples Tuple ordering immaterial Id Name Address Status No duplicates Cardinality of relation = number of tuples 11111111 John 123 Main freshman All tuples in a relation have the same structure; constructed from the same set of attributes 12345678 Mary 456 Cedar sophmore Attributes are named (ordering is immaterial) Value of an attribute is drawn from the attribute s domain 44433322 Art 77 So. 3rd senior There is also a special value null (value unknown or undefined), which belongs to no domain 87654321 Pat 88 No. 4th sophmore Arity of relation = number of attributes Student 11 12 2 Relation Schema Relational Database Relation name Finite set of relations Attribute names & domains Each relation consists of a schema and an Integrity constraints like instance The values of a particular attribute in all tuples Database schema = set of relation schemas are unique constraints among relations (inter-relational The values of a particular attribute in all tuples constraints) are greater than 0 Database instance = set of (corresponding) Default values relation instances 13 14 Database Schema (Example) Integrity Constraints Student (Id: INT, Name: STRING, Address: STRING, Part of schema Status: STRING) Restriction on state (or of sequence of states) of Professor (Id: INT, Name: STRING, DeptId: DEPTS) data base Course (DeptId: DEPTS, CrsName: STRING, Enforced by DBMS CrsCode: COURSES) Intra-relational - involve only one relation Transcript (CrsCode: COURSES, StudId: INT, Part of relation schema e.g., all Ids are unique Grade: GRADES, Semester: SEMESTERS) Inter-relational - involve several relations Department(DeptId: DEPTS, Name: STRING) Part of relation schema or database schema 15 16 Constraint Checking Kinds of Integrity Constraints Automatically checked by DBMS Static restricts legal states of database Protects database from errors Syntactic (structural) Enforces enterprise rules e.g., all values in a column must be unique Semantic (involve meaning of attributes) e.g., cannot register for more than 18 credits Dynamic limitation on sequences of database states e.g., cannot raise salary by more than 5% 17 18 3 Key Constraint A key constraint is a sequence of attributes Key Constraint (cont d) A1, ,An (n=1 possible) of a relation schema, S, with the following property: Superkey - set of attributes containing key A relation instance s of S satisfies the key constraint iff at most one row in s can contain a particular set of (Id, Name) is a superkey of Student values, a1, ,an, for the attributes A1, ,An Every relation has a key Minimality: no subset of A1, ,An is a key constraint Key Relation can have several keys: Set of attributes mentioned in a key constraint primary key: Id in Student (can t be null) e.g., Id in Student, candidate key: (Name, Address) in Student e.g., (StudId, CrsCode, Semester) in Transcript It is minimal: no subset of a key is a key (Id, Name) is not a key of Student 19 20 Foreign Key Constraint Foreign Key Constraint Referential integrity: Item named in one relation must refer to tuples that describe that item in another (Example) Transcript (CrsCode) references Course(CrsCode ) Professor(DeptId) references Department(DeptId) A2 Attribute A1 is a foreign key of R1 referring to attribute A2 in R2, A1 v3 v1 v5 if whenever there is a value v of A1, there is a tuple of R2 in which A has value v, and A is a key of R2 v2 v1 2 2 v3 v6 This is a special case of referential integrity: A must be a candidate key 2 v4 v2 of R2 (e.g., CrsCode is a key of Course in the above) R2 Course null v7 If no row exists in R2 => violation of referential integrity v3 v4 Not all rows of R2 need to be referenced: relationship is not symmetric R1 R2 (e.g., some course might not be taught) Foreign key Value of a foreign key might not be specified (DeptId column of some Candidate key professor might be null) 21 22 Foreign Key (cont d) Foreign Key (cont d) Foreign key might consist of several columns Names of the attrs A1 and A2 need not be the same. (CrsCode, Semester) of Transcript references With tables: (CrsCode, Semester) of Teaching Teaching(CrsCode: COURSES, Sem: SEMESTERS, ProfId: INT) Professor(Id: INT, Name: STRING, DeptId: DEPTS) R1(A1, An) references R2(B1, Bn) ProfId attribute of Teaching references Id attribute of Professor Ai and Bi must have same domains (although not R1 and R2 need not be distinct. necessarily the same names) Employee(Id:INT, MgrId:INT, .) B1, ,Bn must be a candidate key of R2 Employee(MgrId) references Employee(Id) Every manager is also an employee and hence has a unique row in Employee 23 24 4 Inclusion Dependency SQL Referential integrity constraint that is not a foreign key constraint Language for describing database schema Teaching(CrsCode, Semester) references and operations on tables Transcript(CrsCode, Semester) Data Definition Language (DDL): (no empty classes allowed) sublanguage of SQL for describing schema Target attributes do not form a candidate key in Transcript (StudId missing) No simple enforcement mechanism for inclusion dependencies in SQL (requires assertions -- later) 25 26 Table Declaration Tables Student ( Id: , SQL entity that corresponds to a relation Name: (20), Address: (50), An element of the database schema Status: 10) SQL-92 is currently the most supported ) standard but is now superseded by Id Name Address Status SQL:1999 and SQL:2003 101222333 John 10 Cedar St Freshman Database vendors generally deviate from 234567890 Mary 22 Main St Sophomore the standard, but eventually converge 27 Student 28 Primary/Candidate Keys Null Course ( Problem: Not all information might be known when CrsCode (6), row is inserted (e.g., Grade might be missing from CrsName (20), Transcript) DeptId (4), A column might not be applicable for a particular Descr (100), row (e.g., MaidenName if row describes a male) (CrsCode), Solution: Use place holder null DeptId, CrsName) -- candidate key Not a value of any domain (although called null value) ) Indicates the absence of a value Not allowed in certain situations Comments start with 2 dashes Primary keys and columns constrained by 29 30 5 Default Value Semantic Constraints in SQL -Value to be assigned if attribute value in a row Primary key and foreign key are examples is not specified of structural constraints Semantic constraints Student ( Express the logic of the application at hand: Id , e.g., number of registered students maximum Name , enrollment
Recommended publications
  • ACS-3902 Ron Mcfadyen Slides Are Based on Chapter 5 (7Th Edition)
    ACS-3902 Ron McFadyen Slides are based on chapter 5 (7th edition) (chapter 3 in 6th edition) ACS-3902 1 The Relational Data Model and Relational Database Constraints • Relational model – Ted Codd (IBM) 1970 – First commercial implementations available in early 1980s – Widely used ACS-3902 2 Relational Model Concepts • Database is a collection of relations • Implementation of relation: table comprising rows and columns • In practice a table/relation represents an entity type or relationship type (entity-relationship model … later) • At intersection of a row and column in a table there is a simple value • Row • Represents a collection of related data values • Formally called a tuple • Column names • Columns may be referred to as fields, or, formally as attributes • Values in a column are drawn from a domain of values associated with the column/field/attribute ACS-3902 3 Relational Model Concepts 7th edition Figure 5.1 ACS-3902 4 Domains • Domain – Atomic • A domain is a collection of values where each value is indivisible • Not meaningful to decompose further – Specifying a domain • Name, data type, rules – Examples • domain of department codes for UW is a list: {“ACS”, “MATH”, “ENGL”, “HIST”, etc} • domain of gender values for UW is the list (“male”, “female”) – Cardinality: number of values in a domain – Database implementation & support vary ACS-3902 5 Domain example - PostgreSQL CREATE DOMAIN posint AS integer CHECK (VALUE > 0); CREATE TABLE mytable (id posint); INSERT INTO mytable VALUES(1); -- works INSERT INTO mytable VALUES(-1); -- fails https://www.postgresql.org/docs/current/domains.html ACS-3902 6 Domain example - PostgreSQL CREATE DOMAIN domain_code_type AS character varying NOT NULL CONSTRAINT domain_code_type_check CHECK (VALUE IN ('ApprovedByAdmin', 'Unapproved', 'ApprovedByEmail')); CREATE TABLE codes__domain ( code_id integer NOT NULL, code_type domain_code_type NOT NULL, CONSTRAINT codes_domain_pk PRIMARY KEY (code_id) ) ACS-3902 7 Relation • Relation schema R – Name R and a list of attributes: • Denoted by R (A1, A2, ...,An) • E.g.
    [Show full text]
  • (DDL) Reference Manual
    Data Definition Language (DDL) Reference Manual Abstract This publication describes the DDL language syntax and the DDL dictionary database. The audience includes application programmers and database administrators. Product Version DDL D40 DDL H01 Supported Release Version Updates (RVUs) This publication supports J06.03 and all subsequent J-series RVUs, H06.03 and all subsequent H-series RVUs, and G06.26 and all subsequent G-series RVUs, until otherwise indicated by its replacement publications. Part Number Published 529431-003 May 2010 Document History Part Number Product Version Published 529431-002 DDL D40, DDL H01 July 2005 529431-003 DDL D40, DDL H01 May 2010 Legal Notices Copyright 2010 Hewlett-Packard Development Company L.P. Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein. Export of the information contained in this publication may require authorization from the U.S. Department of Commerce. Microsoft, Windows, and Windows NT are U.S. registered trademarks of Microsoft Corporation. Intel, Itanium, Pentium, and Celeron are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
    [Show full text]
  • Relational Database Design Chapter 7
    Chapter 7: Relational Database Design Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional Dependencies Decomposition Boyce-Codd Normal Form Third Normal Form Multivalued Dependencies and Fourth Normal Form Overall Database Design Process Database System Concepts 7.2 ©Silberschatz, Korth and Sudarshan 1 First Normal Form Domain is atomic if its elements are considered to be indivisible units + Examples of non-atomic domains: Set of names, composite attributes Identification numbers like CS101 that can be broken up into parts A relational schema R is in first normal form if the domains of all attributes of R are atomic Non-atomic values complicate storage and encourage redundant (repeated) storage of data + E.g. Set of accounts stored with each customer, and set of owners stored with each account + We assume all relations are in first normal form (revisit this in Chapter 9 on Object Relational Databases) Database System Concepts 7.3 ©Silberschatz, Korth and Sudarshan First Normal Form (Contd.) Atomicity is actually a property of how the elements of the domain are used. + E.g. Strings would normally be considered indivisible + Suppose that students are given roll numbers which are strings of the form CS0012 or EE1127 + If the first two characters are extracted to find the department, the domain of roll numbers is not atomic. + Doing so is a bad idea: leads to encoding of information in application program rather than in the database. Database System Concepts 7.4 ©Silberschatz, Korth and Sudarshan 2 Pitfalls in Relational Database Design Relational database design requires that we find a “good” collection of relation schemas.
    [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]
  • IEEE Paper Template in A4 (V1)
    International Journal of Electrical Electronics & Computer Science Engineering Special Issue - NCSCT-2018 | E-ISSN : 2348-2273 | P-ISSN : 2454-1222 March, 2018 | Available Online at www.ijeecse.com Structural and Non-Structural Query Language Vinayak Sharma1, Saurav Kumar Jha2, Shaurya Ranjan3 CSE Department, Poornima Institute of Engineering and Technology, Jaipur, Rajasthan, India [email protected], [email protected], [email protected] Abstract: The Database system is rapidly increasing and it The most important categories are play an important role in all commercial-scientific software. In the current scenario every field work is related to DDL (Data Definition Language) computer they store their data in the database. Using DML (Data Manipulation Language) database helps to maintain the large records. This paper aims to summarize the different database and their usage in DQL (Data Query Language) IT field. In company database is more appropriate or more 1. Data Definition Language: Data Definition suitable to store the data. Language, DDL, is the subset of SQL that are used by a Keywords: DBS, Database Management Systems-DBMS, database user to create and built the database objects, Database-DB, Programming Language, Object-Oriented examples are deletion or the creation of a table. Some of System. the most Properties of DDL commands discussed I. INTRODUCTION below: CREATE TABLE The database system is used to develop the commercial- scientific application with database. The application DROP INDEX requires set of element for collection transmission, ALTER INDEX storage and processing of data with computer. Database CREATE VIEW system allow the database develop application. This ALTER TABLE paper deal with the features of Nosql and need of Nosql in the market.
    [Show full text]
  • Relational Database Design: FD's & BCNF
    CS145 Lecture Notes #5 Relational Database Design: FD's & BCNF Motivation Automatic translation from E/R or ODL may not produce the best relational design possible Sometimes database designers like to start directly with a relational design, in which case the design could be really bad Notation , , ... denote relations denotes the set of all attributes in , , ... denote attributes , , ... denote sets of attributes Functional Dependencies A functional dependency (FD) has the form , where and are sets of attributes in a relation Formally, means that whenever two tuples in agree on all the attributes of , they must also agree on all the attributes of Example: FD's in Student(SID, SS#, name, CID, grade) Some FD's are more interesting than others: Trivial FD: where is a subset of Example: Nontrivial FD: where is not a subset of Example: Completely nontrivial FD: where and do not overlap Example: Jun Yang 1 CS145 Spring 1999 Once we declare that an FD holds for a relation , this FD becomes a part of the relation schema Every instance of must satisfy this FD This FD should better make sense in the real world! A particular instance of may coincidentally satisfy some FD But this FD may not hold for in general Example: name SID in Student? FD's are closely related to: Multiplicity of relationships Example: Queens, Overlords, Zerglings Keys Example: SID, CID is a key of Student Another de®nition of key: A set of attributes is a key for if (1) ; i.e., is a superkey (2) No proper subset of satis®es (1) Closures of Attribute Sets Given , a set of FD's
    [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]
  • Introduction to Database
    ST. LAWRENCE HIGH SCHOOL A Jesuit Christian Minority Institution STUDY MATERIAL - 12 Subject: COMPUTER SCIENCE Class - 12 Chapter: DBMS Date: 01/08/2020 INTRODUCTION TO DATABASE What is Database? The database is a collection of inter-related data which is used to retrieve, insert and delete the data efficiently. It is also used to organize the data in the form of a table, schema, views, and reports, etc. For example: The college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and delete the information. Database Management System Database management system is a software which is used to manage the database. For example: MySQL, Oracle, etc. are a very popular commercial database which is used in different applications. DBMS provides an interface to perform various operations like database creation, storing data in it, updating data, creating a table in the database and a lot more. It provides protection and security to the database. In the case of multiple users, it also maintains data consistency. DBMS allows users the following tasks: Data Definition: It is used for creation, modification, and removal of definition that defines the organization of data in the database. Data Updation: It is used for the insertion, modification, and deletion of the actual data in the database. Data Retrieval: It is used to retrieve the data from the database which can be used by applications for various purposes. User Administration: It is used for registering and monitoring users, maintain data integrity, enforcing data security, dealing with concurrency control, monitoring performance and recovering information corrupted by unexpected failure.
    [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]
  • Short Type Questions and Answers on DBMS
    BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Short Type Questions and Answers on DBMS Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. DABASE MANAGEMENT SYSTEM SHORT QUESTIONS AND ANSWERS Prepared by Dr.Subhendu Kumar Rath, Dy. Registrar, BPUT. 1. What is database? A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose. 2. What is DBMS? It is a collection of programs that enables user to create and maintain a database. In other words it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications. 3. What is a Database system? The database and DBMS software together is called as Database system. 4. What are the advantages of DBMS? 1. Redundancy is controlled. 2. Unauthorised access is restricted. 3. Providing multiple user interfaces. 4. Enforcing integrity constraints. 5. Providing backup and recovery. 5. What are the disadvantage in File Processing System? 1. Data redundancy and inconsistency. 2. Difficult in accessing data. 3. Data isolation. 4. Data integrity. 5. Concurrent access is not possible. 6. Security Problems. 6. Describe the three levels of data abstraction? The are three levels of abstraction: 1. Physical level: The lowest level of abstraction describes how data are stored. 2. Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data. 3. View level: The highest level of abstraction describes only part of entire database.
    [Show full text]
  • Ddl) Lesson 1
    LESSON 1 . 4 98-364 Database Administration Fundamentals Understand Data Definition Language (DDL) LESSON 1 . 4 98-364 Database Administration Fundamentals Lesson Overview 1.4 Understand data definition language (DDL) In this lesson, you will review: . DDL—DML relationship . DDL . Schema . CREATE . ALTER . DROP LESSON 1 . 4 98-364 Database Administration Fundamentals DDL—DML Relationship DML . Data Manipulation Language. (DML) In a database management system (DBMS), a language that is used to insert data in, update, and query a database. DMLs are often capable of performing mathematical and statistical calculations that facilitate generating reports. Acronym: DML. DML is used to manipulate the data of a database. In lesson review 1.3, you can find more details on DML. LESSON 1 . 4 98-364 Database Administration Fundamentals DDL . Data Definition Language (DDL) A language that defines all attributes and properties of a database, especially record layouts, field definitions, key fields, file locations, and storage strategy. Acronym: DDL. DDL is used to create the framework for the database, the schema of the database, or both. DDL works at the table level of the database. LESSON 1 . 4 98-364 Database Administration Fundamentals Schema . Schema A description of a database to a DBMS in the language provided by the DBMS. A schema defines aspects of the database, such as attributes (fields) and domains and parameters of the attributes. Schemas are generally defined as using commands from a DDL supported by the database system. LESSON 1 . 4 98-364 Database Administration Fundamentals CREATE . There are two forms of the CREATE statement. This statement creates a database called students.
    [Show full text]
  • Data Definition Language (Ddl)
    DATA DEFINITION LANGUAGE (DDL) CREATE CREATE SCHEMA AUTHORISATION Authentication: process the DBMS uses to verify that only registered users access the database - If using an enterprise RDBMS, you must be authenticated by the RDBMS - To be authenticated, you must log on to the RDBMS using an ID and password created by the database administrator - Every user ID is associated with a database schema Schema: a logical group of database objects that are related to each other - A schema belongs to a single user or application - A single database can hold multiple schemas that belong to different users or applications - Enforce a level of security by allowing each user to only see the tables that belong to them Syntax: CREATE SCHEMA AUTHORIZATION {creator}; - Command must be issued by the user who owns the schema o Eg. If you log on as JONES, you can only use CREATE SCHEMA AUTHORIZATION JONES; CREATE TABLE Syntax: CREATE TABLE table_name ( column1 data type [constraint], column2 data type [constraint], PRIMARY KEY(column1, column2), FOREIGN KEY(column2) REFERENCES table_name2; ); CREATE TABLE AS You can create a new table based on selected columns and rows of an existing table. The new table will copy the attribute names, data characteristics and rows of the original table. Example of creating a new table from components of another table: CREATE TABLE project AS SELECT emp_proj_code AS proj_code emp_proj_name AS proj_name emp_proj_desc AS proj_description emp_proj_date AS proj_start_date emp_proj_man AS proj_manager FROM employee; 3 CONSTRAINTS There are 2 types of constraints: - Column constraint – created with the column definition o Applies to a single column o Syntactically clearer and more meaningful o Can be expressed as a table constraint - Table constraint – created when you use the CONTRAINT keyword o Can apply to multiple columns in a table o Can be given a meaningful name and therefore modified by referencing its name o Cannot be expressed as a column constraint NOT NULL This constraint can only be a column constraint and cannot be named.
    [Show full text]