Documente Academic
Documente Profesional
Documente Cultură
1&2
DBMS Functions
1. Data dictionary management
defines data elements (data structure) and their relationships (meta data) provide data abstraction,remove structural + data dependency stores data and related data entry forms, data validation, report definitions, etc. translates logical requests into commands to physically locate and retrieve the requested data (data independence)
1&2
1&2
1&2
1&2
1&2
1&2
2. Distributed:
Supports data distributed across several sites
10
1&2
Database
Logically related data stored in a single logical data repository
eliminate data inconsistency, data anomalies
12
1&2
13
1&2
14
1&2
Attribute
Characteristic of an entity Customer first name, phone, address
Relationship
Association among two or more entities An agent can serve many customers, a customer may be served by one agent. One-to-Many (1:M) Many-to-Many (M:N) One-to-One (1:1)
15
1&2
Business Rules
Brief, precise, and unambiguous description of a policy, procedure, or principle within a specific organizations environment Apply to any organization that stores and uses data to generate information
Description of operations that help to create and enforce actions within that organizations environment Define entities, attributes, relationships and constraints
16
1&2
17
1&2
Standardize companys view of data Constitute a communications tool between users and designers Allow designer to understand the nature, role, and scope of data Allow designer to understand business processes Allow designer to develop appropriate relationship participation rules and constraints
18
1&2
Policy makers
Department managers Written documentation
Procedures
Standards Operations manuals
19
20
1&2
21
1&2
Best understood by examining manufacturing process Best for 1:M relationship that remain fixed over time (same part, same way)
22
1&2
23
24
1&2
25
1&2
26
27
1&2
Relational schema
Visual representation of relational databases entities, attributes of entities, and relationships between entities
28
1&2
A Relational Schema
29
1&2
30
1&2
31
1&2
Easy-to-use
poor design and implementation (slow system + data anomalies)
promote islands of information problems (each department create their own database)
32
1&2
33
1&2
34
1&2
35
1&2
36
1&2
conceptual view visual representation effective communication tools among (database designer, programmers, managers, end users)
Disadvantage
limited constraints representation (eg. GPA between 0 and 4.0) limited relationship representation only between entities, not within entity (eg. classification and credit completed) loss of information content crowed model so ignore attribute mapping
37
1&2
1&2
39
1&2
40
The SQL environment Following Fig. Shows a schematic of an SQL environment Each database is contained in a catalog, which describes any object that is part of the database (regardless of which user created that object). Most companies keep at least two versions of any database they are using. PROD_C is the live production version, which captures real business data and this must be very tightly controlled and monitored. DEV_C is the development version used when the database is being built and continues to serve as a development tool where enhancements and maintenance efforts can be tested before application to the production database. Each database will have a set of schemas associated 41 with a catalog.
1&2
1&2
A simplified
environment
42
1&2
1. Data Definition Language (DDL) commands - that define a database, including creating, altering, and dropping tables and establishing constraints 2. Data Manipulation Language (DML) commands that maintain and query a database 3. Data Control Language (DCL) commands - that control a database, including administering privileges and committing data
43
1&2
DDL,
44
1&2
CHAR(n) fixed-length character data, n characters long Maximum length = 2000 bytes
45
1&2
46
1&2
1&2
48
1&2
49
1&2
Creating tables
Once data model is designed and normalised, the columns needed for each table can be defined using the CREATE TABLE command. The syntax for this is shown in the following Fig. These are the seven steps to follow: 1. Identify the appropriate datatype for each , including length and precision 2. Identify those columns that should accept null values. Column controls that indicate a column cannot be null are established when a table is created and are enforced for every update of the table 50
1&2
Creating tables
3. Identify those columns that need to be UNQUE when the data in that column must have a different value (no duplicates) for each row of data within that table. Where a column or set of columns is designated as UNIQUE, this is a candidate key. Only one candidate key may be designated as a PRIMARY KEY 4. Identify all primary key-foreign key mates. Foreign keys can be established immediately or later by altering the table. The parent table in such a parentchild relationship should be created first. The column constraint REFERENCES can be used to enforce referential integrity
51
1&2
Creating tables
5. Determine values to be inserted into any columns for which a DEFAULT value is desired - can be used to define a value that is automatically inserted when no value is provided during data entry. 6. Identify any columns for which domain specifications may be stated that are more constrained than those established by data type. Using CHECK it is possible to establish validation rules for values to be inserted into the database 7. Create the table and any desired indexes using the CREATE TABLE and CREATE INDEX statements
52
Table creation
General
1&2
53
1&2
Table creation
The following Fig. Shows SQL database definition commands Here some additional column constraints are shown, and primary and foreign keys are given names For example, the CUSTOMER tables primary key is CUSTOMER_ID The primary key constraint is named CUSTOMER_PK, without the constraint name a system identifier would be assigned automatically and the identifier would be difficult to read
54
1&2
55
STEP 1
1&2
Defining
56
STEP2
1&2
Non-nullable
specifications
Note:
57
STEP 3
1&2
Identifying
primary keys
This
58
STEP 4
1&2
Identifying
59
STEPS
5 and 6
1&2
Default
60
STEP 7
1&2
Overall
table definitions
61