الانتقال إلى المحتوى
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.

مشكلة تواجهنى فى ال composite key

Featured Replies

بتاريخ:

تابعت الدروس الملحقة فى المنتدى ووجدت مثال على ال composite primary key
فى صفحة
http://www.araboug.org/ib/index.php?sho...869&hl=composit

لكننى اعمل جدول لفهارس الكتاب منقسم الى جدولين الاول الماستر بة الابواب
و الثانى بة الفصول

و لكى استعمل ال constraint يجب ان يكون على الاقل unique و هذا مستحيل فى فهارس الكتب حيث انها تتماثل و تتكرر فما الحل؟ :rolleyes:

بتاريخ:

Dear Ayman there is many types of constraints
1-primary key which is Unique and not null
2-foreign key which is reference for PK
3-not null
4-unique
5-check

so its not necessary to make the column just primary u can make for example not null

for example u can make ename in the emp table on scott schema not null in the table level as follows:


create table emp (
ename varchar2(25),
.
.
.
.
constraint emp_ename_nn not null(ename));


or u can just type not null besides the column name

for example


create table emp(

ename varchar2(25) not null

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

لم تنجح و رسالة الخطئ هيه

ORA-02270: no matching unique or primary key for this column-list

بتاريخ:

ORA-02270 no matching unique or primary key for this column-list


Cause: An attempt was made to reference a unique or primary key in a table
with a CREATE or ALTER TABLE statement when no such key exists in the
referenced table.
Action: Add the unique or primary key to the table or find the correct names of
the columns with the primary or unique key, and try again

.

بتاريخ:

اخى الكريم
فى الحالة التى ذكرتها لا يمكن استخدام الفصل والابواب لحقل اساسى مركب compsite primary key
ونلجأ فى مثل هذه الاحوال الى استخدام حقل واحد فقط ويعتبر هو الحقل الاساسى للجدول ويسمى فى هذه الحالة Artificial Primary Key

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

يوجل حل للموضوع ببناء جدول واحد يضم الابواب و الفهارس مع بعض
و لكن التصميم الذى اريدة ان يكون الابواب فى جدول و الفصول فى جدول اخر

ولا يمكن الصلة بينهم للتكرار فمينفعش اخد رقم الباب و استعملة fk فى جدول الفصول
لن اطيل عليكم سوف ارسل لكم صورة للمطلوب ان عرف احدكم حلها

غير ذالك يمكن وضع الجميع فى جدول واحد و تنتهى المشكلة

ملحوظة:
فى حالة لو اردت ان تستعمل ال fk
سوف يعمل مع اول كتاب لعدم تكرار ارقام الابواب و الفصول
عند اضافة كتاب جديد لن يعمل

post-3-1106022150_thumb.jpg

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

و دا واجهة الكتاب

post-3-1106027862_thumb.jpg

بتاريخ:

The First Column(Book Series) Make it PK
THEN the other Book Series Fields Make It As FK which references The PK

AND IF you want to add another PK For another Record Dont Make Unique And Not Null As Primary Key


Just Define It As Not null, or Unique or Check

  • بعد 2 أسابيع...
بتاريخ:

CREATE TABLE BOOKS(
 book_id NUMBER, bkname, ...,
 CONSTRAINT books_pk PRIMARY KEY(book_id)
);

CREATE TABLE BOOKSECTIONS(
 book_id NUMBER, bksection NUMBER, sec_title, pgnumber, ...,
 CONSTRAINT booksections_pk PRIMARY KEY(book_id, bksection),
 CONSTRAINT booksections_bookid_fk FOREIGN KEY(book_id)
            REFERENCES books(book_id)
);

CREATE TABLE BOOKCHAPTERS(
 book_id NUMBER, bksection NUMBER, bkchapter NUMBER, ch_title, pgnumber,...,
 CONSTRAINT bookchapters_pk PRIMARY KEY(book_id, bksection, bkchapter),
 CONSTRAINT bookchapters_bookid_fk FOREIGN KEY(book_id)
            REFERENCES books(book_id),
 CONSTRAINT bookid_bksection_fk FOREIGN KEY(book_id, bksection)
            REFERENCES booksections(book_id, bksection)
);

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

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

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

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

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

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.