الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ممكن اتساعدوني بحلي

Featured Replies

بتاريخ:

السلام

اخواني مطلوب مني حل هالسؤال تصميم داتا بيس وحاب اعرض حلي اتمنى الي يشوف فيه غلط يساعدني في تصحيح الخطأ

وعندي سؤال بسيط الجدول الواحد هل من الممكن ان يحتوي على اكثر من foreign key & primary key ولا لا

وهذا نص السؤال المراد حله

A DVD rental shop needs to design a database system for its customers. First a table called DVD has the DVD serial number, title, year, classification. The classification could only the values Drama, Comedy, Action and Documentary. Then another table named Customer includes the customer ID, name, telephone number and address. A Subscription table has the subsections of customers as well as the start date, expiration date and the subscription charge. Furthermore, the table Rent keeps track of customers renting DVDs, price, date of renting and due date. Finally, a table called Return has customers return date of their rented DVDs along with extra costs if any with default value of zero.
Determine the necessary integrity constraints to be enforced on the schemas of the given tables. Make sure the references to Rent table are set to null on deletion, but the others are cascaded. Use the proper data types for the columns, and write the correct DDL SQL statements in Oracle to create the tables. Then, populate the tables with the given data.



create table dvd
(
d_number    number(2)   PRIMARY KEY,
title       varchar(40),
year        number(4),
class       varchar(20) CHECK (class IN('Drama','Comedy','Documentary','Action'))
);



create table customer
(
id 	   varchar(2),
name 	   varchar(10),
address    varchar(20),
tel 	   number(9),
CONSTRAINT customer_id_pk PRIMARY KEY (id)
);



create TABLE subscription
(
id        varchar(2) references customer (id),
s_date    date,
charge    number(2),
expire    date ,
PRIMARY KEY (id,s_date)
);



create table Rent
(
id          varchar(2) references customer (id),
r_number    number(2)  references dvd (d_number),
rent_date   date,
due_date    date,
price       number(2),
PRIMARY KEY (id,R_number ,rent_date)
);



create table return
(
id              varchar(2),
R_number        number(2),
rent_date       date,
return_date     date,
extra_price     number(2) default 0 ,
PRIMARY KEY (id,R_number ,rent_date,return_date),
Foreign key (id,R_number ,rent_date) 
references Rent (id,R_number ,rent_date) on delete cascade  
);

تم تعديل بواسطة xxx7

بتاريخ:

طبعا يجوز عمل جدول به primary key و forigen key

بتاريخ:
  • كاتب الموضوع

اقصد بالجدول الواحد هل من الممكن ان يحتوي على اكثر من primary key و foriegn key

ويا شباب الله خليكم احد يساعدني بحل السؤال

بتاريخ:
  • كاتب الموضوع

يالربع احد يفيدني هل حلي صحيح ولا لا

بتاريخ:

السلام عليكم

اقصد بالجدول الواحد هل من الممكن ان يحتوي على اكثر من primary key و foriegn key


بالنسبة لل foriegn key لايوجد مشكلة فيه عادي جدا ممكن يكون عندك أكثر من واحد يشير إلى جداول أخرى

بالنسبة ل primary key أيضا ممكن كذا حقل مجتمعين معا يكونوا مفتاح أساسي يسمى composite يعني أكثر من حقل يتم وضعهم مفتاح أساسي
مثلا يعني
لو عندك عمود x وعمود y وهما الاثنين مفتاح الاساسي هتكون القيم كده
1--1
1--2
2--1
أهم شيء لايحدث تكرار لل 2 معا تاني
1--2 كده حدث تكرار

ممكن تشوف هذه المواضيع للفهم الاكثر
http://www.araboug.org/ib/index.php?showtopic=32488

http://www.araboug.org/ib/index.php?showtopic=27223
بتاريخ:
  • كاتب الموضوع

شكرا اخ مصطفى

ممكن احد يشوف حلي للسؤال صحيح ولا لا

واتمنى يتم تصليج الخطأ الله خليكم

بتاريخ:

السلام عليكم ورحمة الله

راجع هذا الحل

create table Customer  (
  Customer_ID                            NUMBER(5)            not null,
  customer_name                       VARCHAR2(50),
  customer_telephone_number VARCHAR2(15),
  customer_address                   VARCHAR2(50),
  constraint PK_CUSTOMER primary key (Customer_ID)
)
/

create table DVD  (
  DVD_serial_number  NUMBER(5)                not null,
  DVD_title                   VARCHAR2(50),
  DVD_year                 NUMBER(4),
  DVD_classification  VARCHAR2(10)           not null
  constraint CKC_DVD_CLASSIFICATIO_DVD check (DVD_classification in ('Drama','Comedy','Action','Documentary')),
  constraint PK_DVD primary key (DVD_serial_number)
)
/

create table Rent  (
  Rent_ID                     NUMBER(5)          not null,
  date_of_renting         DATE,
  Customer_ID             NUMBER(5),
  DVD_serial_number  NUMBER(5),
  Rent_price                 NUMBER(3),
  due_date                   DATE,
  constraint PK_RENT primary key (Rent_ID),
  constraint FK_RENT_REFERENCE_CUSTOMER foreign key (Customer_ID)
        references Customer (Customer_ID),
  constraint FK_RENT_REFERENCE_DVD foreign key (DVD_serial_number)
        references DVD (DVD_serial_number)
)
/

create table Return  (
  Return_ID          NUMBER(5)                      not null,
  Rent_ID            NUMBER(5)                       not null,
  return_date        date,
  extra_costs        NUMBER(5)                      default 0,
  constraint PK_RETURN primary key (Return_ID)
)
/

create table Subscription  (
  Customer_ID                                   NUMBER(5)                  not null,
  Subscription_start_date                                          DATE                            not null,
  Subscription_expiration_date        DATE,
  subscription_charge                      NUMBER(3),
  constraint PK_SUBSCRIPTION primary key (Customer_ID, Subscription_start_date),
  constraint FK_SUBSCRIP_REFERENCE_CUSTOMER foreign key (Customer_ID)
        references Customer (Customer_ID)
)
/

create trigger tda_rent after delete on Rent for each row
declare
   integrity_error  exception;
   errno               integer;
   errmsg            char(200);
   dummy            integer;
   found              boolean;

begin --  Set parent code Rent to default in Return
   update Return
    set   Rent_ID =
   where Rent_ID = :old.Rent_ID;

   --  Errors handling
exception
   when integrity_error then
      begin raise_application_error(errno, errmsg);
      end;
end;
/

dvd_rental_shop_image.jpg

بتاريخ:
  • كاتب الموضوع

مشكور اخوي امجد احرجتني بمساعدتك انا كنت بس طالب احد يصلح اخطائي وان شاء الله ماشاء الله عليك حليتلي كل شي شكرا كبيرة خاصة لك اخ امجد

انا اشوفه احسن من حلي وان شاء الله بعتمد عليه

وان شاء الله يكون الحل الصحيح

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.