SanchaiYordprom
9,091 views
32 slides
Mar 29, 2016
Slide 1 of 32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
About This Presentation
Assignment1 of Database
Size: 2.22 MB
Language: none
Added: Mar 29, 2016
Slides: 32 pages
Slide Content
University Database Group 9 010123121 Database Systems Assignment 1
หนังสืออ้างอิง Developing Web-Enabled Decision Support Systems Using VB.NET and ASP.NET by Abhijit A. Pol and Ravindra K. Ahuja
University ER Diagram
ER Diagram to Relation Mapping
Step 1 : Mapping of Regular Entity Types สร้าง Relation Mapping จาก Entity และ Attribute PERSON Name Email Address SSN Phone Nationality Sex FACULTY Rank Jointdate STUDENT Type Class DEPARTMENT Name Address Phone DeptID
COLLEGE Name Address Phone CollegeID SECTION SectionID Year Capacity Semester COURSE CourseID Name CreditHours TextBook
Step 4 : Mapping of Binary 1:N Relationship Types สร้าง foreign key จาก relation FACULTY Rank Jointdate Rank Jointdate StartDate F_SSN F_DeptID STUDENT Type Class Type Class Grade S_SSN S_DeptID
DEPARTMENT Name Address Phone DeptID Name Address Phone DeptID Dept_CollegeID SECTION SectionID Year Capacity Semester SectionID Year Capacity Semester Fac_ID Cou_ID COURSE CourseID Name CreditHours TextBook CourseID Name CreditHours TextBook Cou_DeptID
PERSON : ชื่อ อีเมล์ ที่อยู่ รหัสบัตรประชาชน เบอร์โทรศัพท์มือถือ สัญชาติ และ เพศ FACULTY : ระดับ วันที่เข้าร่วม STUDENT : type class DEPARTMENT : ชื่อ ที่อยู่ เบอร์โทรศัพท์มือถือ department ID COLLEGE : ชื่อ ที่อยู่ เบอร์โทรศัพท์มือถือ college ID SECTION : section ID ปีที่เรียน ความจุของนักเรียน เทอม COURSE : course ID ชื่อ course หน่วยกิต หนังสือเรียน การเก็บข้อมูล
Example Generate Code Sqlite3 ###Person Generate### import random, string, sqlite3 from string import ascii_lowercase from random import randint conn = sqlite3.connect(' university.db ') c = conn.cursor () i = 1 key = 1 city = ['A','B','C','D','E','F'] nationalities = [' Thai','Chinese','American '] sexs = ['Male' , 'Female']
while i <= 100000000: fname = ''.join( random.choice ( ascii_lowercase ) for i in range(5)) lname = ''.join( random.choice ( ascii_lowercase ) for i in range(5)) person_name = fname + ' ' + lname email = ''.join( random.choice ( ascii_lowercase ) for i in range(5)) + '@mail.com' address = str ( randint (0,300))+' '+city[ randint (0,5)] ssn = key phone = random.randint (0000000000,9999999999) nationality = nationalities[ randint (0,2)] sex = sexs [ randint (0,1)]
exec_str = 'insert into PERSON values ("'+ person_name +'","'+email+'","'+address+'",'+ str ( ssn )+','+ str (phone)+',"'+nationality+'","'+sex+'")' c.execute ( exec_str ) if((i%10000)==0): conn.commit () print( i ) key = key+1 i = i+1 conn.commit () conn.close ()