Nội dung của Bài 11: Các thao tác với cơ sở dữ liệu quan hệ dưới đây, các em sẽ được tìm hiểu về các chức năng mà hệ QTCSDL quan hệ phải có và vai trò, ý nghĩa của chức năng đó trong quá trình tạo lập và khai thác hệ QTCSDL quan hệ. Mời các em cùng theo dõi nội dung chi tiết của bài học.

1. Tạo lập CSDL

  • Tạo bảng: B­ước đầu tiên trong việc tạo lập một CSDL quan hệ là tạo ra một hay nhiều bảng. Để thực hiện điều đó, cần phải khai báo cấu trúc bảng, bao gồm:
    • Đặt tên các trường;
    • Chỉ định kiểu dữ liệu cho mỗi trường;
    • Khai báo kích thước của trường.

Một ví dụ về giao diện để tạo bảng như trong hình 1 dưới đây:

Hình 1. Giao diện tạo bảng trong Access 

  • Chọn khoá chính cho bảng bằng cách để hệ QTCSDL tự động chọn hoặc ta xác định khoá thích hợp trong các khoá của bảng làm khoá chính.
  • Đặt tên bảng và lưu cấu trúc bảng.
  • Tạo liên kết giữa các bảng bằng cách xác định các trường chung trong các bảng. Liên kết giúp hệ QTCSDL biết kết nối các bảng như thế nào để phục vụ việc kết xuất thông tin.

Ngoài ra, như đã được giới thiệu ở chương II, các hệ QTCSDL đều cho phép ta có thể thay đổi cấu trúc bảng, thay đổi khoá chính và xóa bảng…

2. Cập nhật dữ liệu

  • Sau khi tạo cấu trúc ta có thể nhập dữ liệu cho bảng. Thông thường việc nhập dữ liệu được thực hiện từ bàn phím. Quá trình cập nhật đảm bảo một số ràng buộc toàn vẹn đã được khai báo.
  • Phần lớn các hệ QTCSDL cho phép tạo ra biểu mẫu nhập dữ liệu (hình 2) để việc nhập dễ dàng hơn, nhanh hơn và hạn chế khả năng nhầm lẫn.
  • Dữ liệu nhập vào có thể được chỉnh sửa, thêm, xoá:
    • Thêm bản ghi bằng cách bổ sung một hoặc một vài bộ dữ liệu vào bảng
    • Chỉnh sửa dữ liệu là việc thay đổi các giá trị của một vài thuộc tínhcủa một bộ.
    • Xoá bản ghi là việc xoá một hoặc một số bộ của bảng.

Hình 2. Biểu mẫu nhập dữ liệu trong hệ QTCSDL Foxpro

3. Khai thác CSDL

a. Sắp xếp các bản ghi

  • Một trong những việc mà một hệ QTCSDL thường phải thực hiện là tổ chức hoặc cung cấp phư­ơng tiện truy cập các bản ghi theo một trình tự nào đó.
  • Ta có thể hiển thị trên màn hình hay in ra các bản ghi theo trình tự này.
  • Các bản ghi có thể được sắp xếp theo nội dung của một hay nhiều trường.

Ví dụ: Có thể xếp danh sách học sinh theo bảng chữ cái của trường tên (hình 3), hoặc theo thứ tự giảm dần của ngày sinh:

Hình 3. Dữ liệu được sắp xếp tên theo bảng chữ cái 

b. Truy vấn CSDL

Truy vấn là một phát biểu thể hiện yêu cầu của người dùng.

Để phục vụ được việc truy vấn CSDL, thông thư­ờng các hệ QTCSDL cho phép nhập các biểu thức hay các tiêu chí nhằm các mục đích sau:

  • Định vị các bản ghi;
  • Thiết lập liên kết giữa các bảng để kết xuất thông tin;
  • Liệt kê một tập con các bản ghi hoặc tập con các trường;
  • Thực hiện các phép toán;
  • Thực hiện các thao tác quản lí dữ liệu khác.

SQL là một công cụ mạnh trong các hệ QTCSDL quan hệ thông dụng hiện nay. Nó cho phép người dùng thể hiện truy vấn mà không cần biết nhiều về cấu trúc CSDL.

c. Xem dữ liệu

Thông thư­ờng các hệ QTCSDL cung cấp nhiều cách xem dữ liệu:

  • Có thể xem toàn bộ bảng, tuy nhiên với những bảng có nhiều trường và kích thước trường lớn thì việc xem toàn bộ bảng khó thực hiện, màn hình chỉ có thể hiển thị một phần của bảng.
  • Có thể dùng công cụ lọc dữ liệu để xem một tập con các bản ghi hoặc một số trường trong một bảng.
  • Các hệ QTCSDL quan hệ quen thuộc cũng cho phép tạo ra các biểu mẫu để xem các bản ghi. Các biểu mẫu này giống với các biểu mẫu nhập dữ liệu về mặt thiết kế, chỉ khác là chúng được sử dụng để hiển thị dữ liệu sẵn có chứ không phải để tiếp nhận dữ liệu mới. Ta có thể tạo ra các chế độ hiển thị dữ liệu đơn giản, dễ hiểu, chỉ hiển thị mỗi lần một bản ghi. Dùng các biểu mẫu phức tạp có thể hiển thị các thông tin có liên quan được kết xuất từ nhiều bảng.

Hình 4. Ví dụ về biểu mẫu hiển thị dữ liệu

d. Kết xuất báo cáo

  • Thông tin trong một báo cáo được thu thập bằng cách tập hợp dữ liệu theo các tiêu chí do người dùng đặt ra.
  • Báo cáo thư­ờng được in ra hay hiển thị trên màn hình theo khuôn mẫu định sẵn.
  • Cũng như biểu mẫu, báo cáo có thể xây dựng dựa trên các truy vấn.

64 BÌNH LUẬN

  1. Do you mind if I quote a couple of your articles as long as I provide credit and sources back
    to your blog? My blog is in the exact same area of interest as
    yours and my users would genuinely benefit from a lot of the information you present here.
    Please let me know if this alright with you.
    Thank you!

  2. หากคุณไม่มั่นใจในการเริ่มโปรเจ็คใหม่ของคุณ หรือต้องการทราบขอบเขตของงาน เราสามารถเป็นที่ปรึกษาในทุกข้อสงสัย
    และจะช่วยคุณตลอดการดำเนินงานของคุณ สามารถติดต่อเข้ามาพูดคุยกับเราก่อนได้

    เรามุ่งนำเสนอการบริการให้กับกลุ่มลูกค้าที่หลากหลาย เริ่มจากกลุ่มลูกค้าสตาร์ทอัพขนาดเล็กไปจนถึงธุรกิจขนาดใหญ่ หัวใจสำคัญของเราคือการนำผลประโยชน์ในด้านเชิงพาณิชย์มาสู่ธุรกิจของคุณ โดยการดำเนินผ่านเว็บไซต์ที่สวยงามกับฟังชั่นที่เพรียบพร้อม

    It appears like you were being misusing this aspect by likely way too quickly.
    You’ve been temporarily blocked from working with it.

    หากคุณต้องการงานภาพกราฟิกดีไซน์ที่มีคุณภาพในขอนแก่น เราคือคำตอบการงานกราฟิกชั้นนำในขอนแก่น
    ที่มีรูปแบบดีไซน์ที่หลากหลายและเป็นสากล

    เยส เว็บ ดีไซน์ สตูดิโอ เป็นบริษัทที่รับออกแบบเว็บไซต์
    ที่เชี่ยวชาญในการออกแบบเว็บไซต์และพัฒนาเว็บไซต์ให้กับลูกค้าที่ขอนแก่น เราคือบริษัททำเว็บไซต์หนึ่งเดียวในขอนแก่น ที่มีการออกแบบที่โดดเด่นไม่เหมือนใคร

    ติวเตอร์ และผู้เชี่ยวชาญที่ให้ความรู้เฉพาะด้าน

    You’re using a browser that isn’t supported by Facebook, so we have redirected you to an easier version to give you the very best
    experience.

    กับวิธีรับมือที่จะช่วยให้โฆษณายังคงมีประสิทธิภาพสูงสุด รักเราให้เหมือนที่เรารักคุณ ติดตามเราได้เลย!

    เราดูแลลูกค้าด้วยการให้คำปรึกษาอย่างละเอียด และเมื่อเราเข้าใจเป้าหมายและข้อกำหนดของแบรนด์นั้นๆ แล้ว เราจะสามารถสร้างแคมเปญที่มีประสิทธิภาพ ซึ่งจะช่วยให้บริษัทของคุณเติบโตไปในทิศทางที่ดีที่สุด ไม่ว่าจะเป็นยอดการเข้าชมที่มากขึ้น คอนเวอร์ชั่นเรทที่สูงขึ้น การจัดอันดับที่ดีขึ้น หรือรายได้ที่มีนัยสำคัญยิ่งขึ้น ซึ่งเราจะทำการออกแบบกลยุทธ์เพื่อให้เหมาะกับกลุ่มลูกค้าและเป้าหมายของคุณมากที่สุด

    บริการทำการตลาดออนไลน์ เพิ่มยอดขายสินค้า โดยทีมงานมืออาชีพ

    “เราคือไพรมอล เราเป็นทีมนักการตลาดดิจิทัลระดับ⁠ท็อปของไทยที่ใส่ใจลูกค้าและมุ่งสู่ผลลัพธ์ที่ดีที่สุด”

    สิ่งที่จะได้รับเมื่อใช้บริการกับเรา

    บริการออกแบบเว็บไซต์ด้วยดีไซน์ชั้นนำของจังหวัดขอนแก่น

    เขียนแบบวิศวกรรมและออกแบบโครงสร้าง

    It appears like you had been misusing this characteristic by heading as well quickly.
    You’ve been quickly blocked from making use of
    it.

    ให้เว็บไซต์ ไต่อันดับสูงขึ้น และมีคนเข้าเยอะกว่าเดิม

    You might be utilizing a browser that won’t supported by Facebook, so we have redirected you to definitely a simpler Edition to provde the
    very best experience.

  3. Hello! I’m at work browsing your blog from my new apple
    iphone! Just wanted to say I love reading through your blog and
    look forward to all your posts! Carry on the outstanding work!

  4. I’m not sure where you’re getting your information, but good
    topic. I needs to spend some time learning much
    more or understanding more. Thanks for excellent information I was looking for this info
    for my mission.

  5. You really make it seem so easy with your presentation but I find this matter to be actually something that I think I would never understand.
    It seems too complex and extremely broad for
    me. I am looking forward for your next post, I will try to get the hang of it!

  6. Do you have a spam issue on this website; I also am a
    blogger, and I was curious about your situation; many
    of us have developed some nice practices and we are looking to exchange solutions
    with other folks, be sure to shoot me an email if interested.

  7. I like the helpful information you provide for your articles.
    I’ll bookmark your blog and take a look at once more right here frequently.

    I am rather certain I will be told many new stuff right here!

    Good luck for the next!

  8. Greate article. Keep writing such kind of info on your page.
    Im really impressed by your site.
    Hello there, You’ve performed a great job. I’ll certainly digg it and in my view suggest
    to my friends. I am confident they’ll be benefited from this website.

  9. Spot on with this write-up, I truly believe this amazing site needs a lot more attention.
    I’ll probably be returning to see more, thanks for the
    advice!

  10. Thank you for another informative blog. The place else may just I get that kind of information written in such an ideal means?
    I’ve a project that I’m just now operating on, and I have
    been on the look out for such info.

  11. Appreciating the commitment you put into your blog and detailed information you
    present. It’s nice to come across a blog every once in a while that isn’t the same outdated rehashed material.

    Wonderful read! I’ve bookmarked your site and I’m including
    your RSS feeds to my Google account.

  12. I’m not certain the place you are getting your info, but great topic.
    I must spend some time studying much more or working out more.
    Thanks for excellent information I used to be
    looking for this info for my mission.

  13. you’re really a good webmaster. The site loading pace is incredible.
    It kind of feels that you’re doing any unique trick.
    Also, The contents are masterwork. you have done a great job in this subject!

  14. I’m really loving the theme/design of your weblog.
    Do you ever run into any web browser compatibility issues?
    A couple of my blog readers have complained about my website
    not operating correctly in Explorer but looks great in Firefox.
    Do you have any ideas to help fix this issue?

  15. Hi there i am kavin, its my first occasion to commenting anyplace, when i read this
    paragraph i thought i could also create comment due to this
    brilliant piece of writing.

  16. Hey there superb blog! Does running a blog similar to this take a
    massive amount work? I have absolutely no expertise in computer programming however I was hoping to start
    my own blog soon. Anyhow, should you have any ideas or tips for new blog
    owners please share. I know this is off subject but I
    just had to ask. Appreciate it!

  17. Hello There. I discovered your blog using msn. That is
    an extremely well written article. I’ll make sure to bookmark
    it and return to learn extra of your helpful information. Thanks
    for the post. I will definitely return.

  18. Hmm is anyone else encountering problems with the
    pictures on this blog loading? I’m trying to determine if its a problem
    on my end or if it’s the blog. Any responses would be greatly appreciated.

  19. May I just say what a relief to uncover an individual who actually understands what
    they’re discussing over the internet. You definitely know how to bring a
    problem to light and make it important. More people ought to read this
    and understand this side of the story. I was surprised that you aren’t more
    popular since you certainly have the gift.

  20. I blog often and I truly thank you for your content.

    The article has truly peaked my interest. I will bookmark your blog and keep
    checking for new information about once per week.
    I opted in for your Feed as well.

  21. Very good blog! Do you have any tips and hints for aspiring writers?
    I’m hoping to start my own site soon but I’m a little lost on everything.

    Would you recommend starting with a free platform like WordPress or go for a paid option? There
    are so many choices out there that I’m completely confused ..
    Any recommendations? Bless you!

  22. You could certainly see your expertise within the work you write.

    The arena hopes for even more passionate writers like
    you who aren’t afraid to say how they believe. At all times follow your heart.

  23. Hi fantastic blog! Does running a blog like this require
    a lot of work? I have absolutely no knowledge of coding however I was hoping to start my own blog in the near future.
    Anyhow, if you have any ideas or techniques for new blog owners please share.
    I understand this is off subject nevertheless I simply needed to ask.
    Many thanks!

  24. Greate pieces. Keep posting such kind of info on your blog.

    Im really impressed by your site.
    Hello there, You’ve performed a fantastic job. I will definitely digg it and personally suggest
    to my friends. I am confident they’ll be benefited from this
    website.

  25. It’s appropriate time to make some plans for the future and
    it’s time to be happy. I have read this post and if I could I wish to suggest you few
    interesting things or tips. Maybe you can write next articles
    referring to this article. I desire to read more things about it!

  26. Having read this I believed it was very enlightening.
    I appreciate you taking the time and effort to put this information together.

    I once again find myself personally spending a significant amount of time both reading and leaving comments.
    But so what, it was still worth it!

  27. hello there and thank you for your info – I’ve definitely picked up anything new from right here.
    I did however expertise several technical points using this site,
    since I experienced to reload the site lots of times previous to I could get it to load properly.
    I had been wondering if your web host is OK? Not that I’m complaining,
    but sluggish loading instances times will very frequently affect your placement
    in google and could damage your quality score if advertising and marketing with Adwords.
    Anyway I am adding this RSS to my email and can look out for a lot
    more of your respective interesting content.
    Ensure that you update this again soon.

  28. We stumbled over here different web page and thought I might as well check things out.

    I like what I see so now i’m following you.
    Look forward to looking over your web page repeatedly.

  29. Hey there I am so thrilled I found your webpage, I really found you by mistake, while I
    was researching on Bing for something else, Anyhow I
    am here now and would just like to say kudos for a incredible post and a
    all round entertaining blog (I also love the theme/design), I don’t
    have time to browse it all at the moment but I have saved it and also added your RSS feeds,
    so when I have time I will be back to read a lot more,
    Please do keep up the awesome b.

  30. I am extremely impressed with your writing skills and also with the layout on your weblog.
    Is this a paid theme or did you customize it yourself?
    Either way keep up the nice quality writing, it’s rare to see a great blog like this one these days.

  31. Fantastic blog! Do you have any suggestions for aspiring writers?
    I’m planning to start my own blog soon but I’m a little lost on everything.
    Would you suggest starting with a free platform
    like WordPress or go for a paid option? There are so
    many options out there that I’m totally confused .. Any ideas?

    Thank you!

  32. Excellent post. I was checking continuously this blog and I am impressed!

    Extremely helpful info specifically the closing phase 🙂 I handle such information much.
    I used to be seeking this particular info for a very lengthy time.

    Thank you and good luck.

  33. Wonderful work! This is the type of information that are supposed to be shared
    across the internet. Disgrace on the seek engines for
    not positioning this post upper! Come on over and talk over with
    my web site . Thank you =)

  34. That is really fascinating, You are a very professional blogger.
    I have joined your feed and look ahead to in the hunt for
    extra of your fantastic post. Also, I’ve shared your site in my social networks

  35. you’re truly a good webmaster. The web site loading pace is incredible.
    It sort of feels that you’re doing any distinctive trick.
    Furthermore, The contents are masterwork. you have performed
    a wonderful activity in this topic!

  36. Hello I am so happy I found your site, I really found you by mistake, while I was searching on Aol for something else, Anyhow I am here now and
    would just like to say cheers for a remarkable post and a all round interesting blog (I also love the theme/design), I don’t have time to read through it all at
    the minute but I have book-marked it and also added your
    RSS feeds, so when I have time I will be back to read much more,
    Please do keep up the great work.

  37. Hey I know this is off topic but I was wondering if you
    knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some
    time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading
    your blog and I look forward to your new updates.

  38. Very nice post. I just stumbled upon your blog and
    wished to say that I’ve truly enjoyed surfing around your blog posts.
    In any case I’ll be subscribing to your rss feed and I hope you
    write again soon!

THOÁT KHỎI BÌNH LUẬN

Please enter your comment!
Please enter your name here